Skip to content

Commit

Permalink
Merge pull request #18 from AlchemyCMS/fqcn
Browse files Browse the repository at this point in the history
Fully qualify the names of Serializer classes
  • Loading branch information
mamhoff authored Nov 16, 2020
2 parents 12399b3 + fbaba0e commit 53b509f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/serializers/alchemy/json_api/element_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ElementSerializer
)
belongs_to :parent_element, record_type: :element, serializer: self

belongs_to :page, record_type: :page, serializer: PageSerializer
belongs_to :page, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer

has_many :essences, polymorphic: true do |element|
element.contents.map(&:essence)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class EssenceNodeSerializer
essence&.node&.name
end

belongs_to :node, record_type: :node, serializer: NodeSerializer
belongs_to :node, record_type: :node, serializer: ::Alchemy::JsonApi::NodeSerializer

with_options if: proc { |essence| essence.node.present? } do
attribute :name do |essence|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class EssencePageSerializer
essence.page&.url_path
end

has_one :page, record_type: :page, serializer: PageSerializer
has_one :page, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer
end
end
end
6 changes: 3 additions & 3 deletions app/serializers/alchemy/json_api/language_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class LanguageSerializer
:locale,
)

has_many :menu_items, record_type: :node, serializer: NodeSerializer, object_method_name: :nodes, id_method_name: :node_ids
has_many :menu_items, record_type: :node, serializer: ::Alchemy::JsonApi::NodeSerializer, object_method_name: :nodes, id_method_name: :node_ids

has_many :menus, record_type: :node, serializer: NodeSerializer do |language|
has_many :menus, record_type: :node, serializer: ::Alchemy::JsonApi::NodeSerializer do |language|
language.nodes.select { |n| n.parent.nil? }
end
has_many :pages
has_one :root_page, record_type: :page, serializer: PageSerializer
has_one :root_page, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer

with_options if: ->(_, params) { params[:admin] == true } do
attribute :created_at
Expand Down
8 changes: 4 additions & 4 deletions app/serializers/alchemy/json_api/page_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class PageSerializer
:updated_at,
)

belongs_to :language, record_type: :language, serializer: LanguageSerializer
belongs_to :language, record_type: :language, serializer: ::Alchemy::JsonApi::LanguageSerializer

has_many :elements, record_type: :element, serializer: ElementSerializer
has_many :fixed_elements, record_type: :element, serializer: ElementSerializer
has_many :elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer
has_many :fixed_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer

has_many :all_elements, record_type: :element, serializer: ElementSerializer do |page|
has_many :all_elements, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |page|
page.all_elements.select { |e| e.public? && !e.trashed? }
end

Expand Down
2 changes: 1 addition & 1 deletion lib/alchemy/json_api/essence_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module JsonApi
module EssenceSerializer
def self.included(klass)
klass.include FastJsonapi::ObjectSerializer
klass.has_one :element, record_type: :element, serializer: ElementSerializer do |essence|
klass.has_one :element, record_type: :element, serializer: ::Alchemy::JsonApi::ElementSerializer do |essence|
essence.content.element
end
klass.attributes :ingredient
Expand Down

0 comments on commit 53b509f

Please sign in to comment.