-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from AlchemyCMS/use-full-module-path
Use full module paths in serializers
- Loading branch information
Showing
12 changed files
with
153 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
# frozen_string_literal: true | ||
module Alchemy::JsonApi | ||
class ElementSerializer | ||
include FastJsonapi::ObjectSerializer | ||
attributes( | ||
:position, | ||
:created_at, | ||
:updated_at, | ||
) | ||
attribute :element_type, &:name | ||
belongs_to :parent_element, record_type: :element, serializer: self | ||
module Alchemy | ||
module JsonApi | ||
class ElementSerializer | ||
include FastJsonapi::ObjectSerializer | ||
attributes( | ||
:position, | ||
:created_at, | ||
:updated_at, | ||
) | ||
attribute :element_type, &:name | ||
belongs_to :parent_element, record_type: :element, serializer: self | ||
|
||
belongs_to :page | ||
has_many :essences, polymorphic: true do |element| | ||
element.contents.map(&:essence) | ||
end | ||
belongs_to :page | ||
has_many :essences, polymorphic: true do |element| | ||
element.contents.map(&:essence) | ||
end | ||
|
||
has_many :nested_elements, record_type: :element, serializer: self | ||
has_many :nested_elements, record_type: :element, serializer: self | ||
|
||
with_options if: ->(_, params) { params[:admin] == true } do | ||
attribute :tag_list | ||
attribute :display_name, &:display_name_with_preview_text | ||
with_options if: ->(_, params) { params[:admin] == true } do | ||
attribute :tag_list | ||
attribute :display_name, &:display_name_with_preview_text | ||
end | ||
end | ||
end | ||
end |
8 changes: 5 additions & 3 deletions
8
app/serializers/alchemy/json_api/essence_boolean_serializer.rb
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,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceBooleanSerializer | ||
include EssenceSerializer | ||
module Alchemy | ||
module JsonApi | ||
class EssenceBooleanSerializer | ||
include EssenceSerializer | ||
end | ||
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,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceDateSerializer | ||
include EssenceSerializer | ||
module Alchemy | ||
module JsonApi | ||
class EssenceDateSerializer | ||
include EssenceSerializer | ||
end | ||
end | ||
end |
36 changes: 19 additions & 17 deletions
36
app/serializers/alchemy/json_api/essence_file_serializer.rb
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,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceHtmlSerializer | ||
include EssenceSerializer | ||
module Alchemy | ||
module JsonApi | ||
class EssenceHtmlSerializer | ||
include EssenceSerializer | ||
end | ||
end | ||
end |
16 changes: 9 additions & 7 deletions
16
app/serializers/alchemy/json_api/essence_link_serializer.rb
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,12 +1,14 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceLinkSerializer | ||
include EssenceSerializer | ||
attributes( | ||
:link_title, | ||
:link_target, | ||
) | ||
module Alchemy | ||
module JsonApi | ||
class EssenceLinkSerializer | ||
include EssenceSerializer | ||
attributes( | ||
:link_title, | ||
:link_target, | ||
) | ||
end | ||
end | ||
end |
40 changes: 21 additions & 19 deletions
40
app/serializers/alchemy/json_api/essence_node_serializer.rb
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
28 changes: 15 additions & 13 deletions
28
app/serializers/alchemy/json_api/essence_page_serializer.rb
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,22 +1,24 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssencePageSerializer | ||
include EssenceSerializer | ||
module Alchemy | ||
module JsonApi | ||
class EssencePageSerializer | ||
include EssenceSerializer | ||
|
||
attribute :ingredient do |essence| | ||
essence.page&.url_path | ||
end | ||
attribute :ingredient do |essence| | ||
essence.page&.url_path | ||
end | ||
|
||
attribute :page_name do |essence| | ||
essence.page&.name | ||
end | ||
attribute :page_name do |essence| | ||
essence.page&.name | ||
end | ||
|
||
attribute :page_url do |essence| | ||
essence.page&.url_path | ||
end | ||
attribute :page_url do |essence| | ||
essence.page&.url_path | ||
end | ||
|
||
has_one :page, record_type: :page, serializer: PageSerializer | ||
has_one :page, record_type: :page, serializer: PageSerializer | ||
end | ||
end | ||
end |
56 changes: 29 additions & 27 deletions
56
app/serializers/alchemy/json_api/essence_picture_serializer.rb
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
16 changes: 9 additions & 7 deletions
16
app/serializers/alchemy/json_api/essence_richtext_serializer.rb
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,12 +1,14 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceRichtextSerializer | ||
include EssenceSerializer | ||
attributes( | ||
:body, | ||
:stripped_body, | ||
) | ||
module Alchemy | ||
module JsonApi | ||
class EssenceRichtextSerializer | ||
include EssenceSerializer | ||
attributes( | ||
:body, | ||
:stripped_body, | ||
) | ||
end | ||
end | ||
end |
8 changes: 5 additions & 3 deletions
8
app/serializers/alchemy/json_api/essence_select_serializer.rb
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,8 +1,10 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceSelectSerializer | ||
include EssenceSerializer | ||
module Alchemy | ||
module JsonApi | ||
class EssenceSelectSerializer | ||
include EssenceSerializer | ||
end | ||
end | ||
end |
20 changes: 11 additions & 9 deletions
20
app/serializers/alchemy/json_api/essence_text_serializer.rb
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,16 @@ | ||
# frozen_string_literal: true | ||
require "alchemy/json_api/essence_serializer" | ||
|
||
module Alchemy::JsonApi | ||
class EssenceTextSerializer | ||
include EssenceSerializer | ||
attributes( | ||
:body, | ||
:link_title, | ||
:link_target, | ||
) | ||
attribute :link_url, &:link | ||
module Alchemy | ||
module JsonApi | ||
class EssenceTextSerializer | ||
include EssenceSerializer | ||
attributes( | ||
:body, | ||
:link_title, | ||
:link_target, | ||
) | ||
attribute :link_url, &:link | ||
end | ||
end | ||
end |