-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start using jsonapi-serializer gem instead of active_model_serializers
- Loading branch information
1 parent
12bd083
commit d106230
Showing
28 changed files
with
143 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class BaseSerializer | ||
include JSONAPI::Serializer | ||
|
||
def as_json(options={}) | ||
serializable_hash[:data] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
class CourtOrderSerializer < NoticeSerializer | ||
attribute :laws_referenced | ||
|
||
def laws_referenced | ||
attribute :laws_referenced do |object| | ||
object.laws_referenced.map(&:name) | ||
end | ||
|
||
private | ||
attributes_to_serialize.delete(:body) | ||
attribute :explanation, &:body | ||
|
||
def attributes | ||
attributes = super | ||
swap_keys(attributes, :body, :explanation) | ||
attributes[:works].each do |work| | ||
attribute :works do |object| | ||
works(object).each do |work| | ||
swap_keys(work, 'description', 'subject_of_court_order') | ||
swap_keys(work, 'infringing_urls', 'targetted_urls') | ||
work.delete('copyrighted_urls') | ||
end | ||
attributes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
class DataProtectionSerializer < NoticeSerializer | ||
def attributes | ||
attributes = super | ||
swap_keys(attributes, :body, :legal_complaint) | ||
attributes[:works].each do |work| | ||
attributes_to_serialize.delete(:body) | ||
attribute :legal_complaint, &:body | ||
|
||
attribute :works do |object| | ||
works(object).each do |work| | ||
swap_keys(work, 'infringing_urls', 'urls_mentioned_in_request') | ||
end | ||
attributes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
class DefamationSerializer < NoticeSerializer | ||
def attributes | ||
attributes = super | ||
swap_keys(attributes, :body, :legal_complaint) | ||
attributes[:works].each do |work| | ||
attributes_to_serialize.delete(:body) | ||
attribute :legal_complaint, &:body | ||
|
||
attribute :works do |object| | ||
works(object).each do |work| | ||
swap_keys(work, 'infringing_urls', 'defamatory_urls') | ||
work.delete('copyrighted_urls') | ||
end | ||
attributes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
class EntitySerializer < ActiveModel::Serializer | ||
attributes :id, :parent_id, :name, :country_code, :url | ||
class EntitySerializer < BaseSerializer | ||
attributes :id, :parent_id, :name, :country_code, :url | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
class LawEnforcementRequestSerializer < NoticeSerializer | ||
attributes :regulations, :request_type | ||
|
||
def regulations | ||
attribute :regulations do |object| | ||
object.regulation_list.map(&:name) | ||
end | ||
|
||
private | ||
attributes_to_serialize.delete(:body) | ||
attribute :explanation, &:body | ||
|
||
def attributes | ||
attributes = super | ||
swap_keys(attributes, :body, :explanation) | ||
attributes[:works].each do |work| | ||
attribute :works do |object| | ||
works(object).each do |work| | ||
swap_keys(work, 'description', 'subject_of_enforcement_request') | ||
swap_keys(work, 'copyrighted_urls', 'original_work_urls') | ||
swap_keys(work, 'infringing_urls', 'urls_in_request') | ||
end | ||
attributes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
class OtherSerializer < NoticeSerializer | ||
private | ||
attributes_to_serialize.delete(:body) | ||
attribute :explanation, &:body | ||
|
||
def attributes | ||
attributes = super | ||
swap_keys(attributes, :body, :explanation) | ||
attributes[:works].each do |work| | ||
attribute :works do |object| | ||
works(object).each do |work| | ||
swap_keys(work, 'description', 'complaint') | ||
swap_keys(work, 'copyrighted_urls', 'original_work_urls') | ||
swap_keys(work, 'infringing_urls', 'problematic_urls') | ||
end | ||
attributes | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
class PrivateInformationSerializer < NoticeSerializer | ||
private | ||
attributes_to_serialize.delete(:body) | ||
attribute :explanation, &:body | ||
|
||
def attributes | ||
attributes = super | ||
swap_keys(attributes, :body, :explanation) | ||
attributes[:works].each do |work| | ||
attribute :works do |object| | ||
works(object).each do |work| | ||
swap_keys(work, 'description', 'complaint') | ||
swap_keys(work, 'infringing_urls', 'urls_with_private_information') | ||
end | ||
attributes | ||
end | ||
end |
Oops, something went wrong.