Class: Ecoportal::API::GraphQL::Base::Page::Section
- Inherits:
-
Logic::BaseModel
- Object
- Common::Content::DoubleModel
- Common::GraphQL::Model
- Logic::BaseModel
- Ecoportal::API::GraphQL::Base::Page::Section
- Defined in:
- lib/ecoportal/api/graphql/base/page/section.rb
Overview
Wraps a SectionUnion doc (ContentSection or SplitSection). Provides access to heading, type, and data fields within the section.
Direct Known Subclasses
Constant Summary
Constants included from Common::GraphQL::Model::Diffable
Common::GraphQL::Model::Diffable::DIFF_CLASS
Instance Method Summary collapse
-
#components ⇒ Object
(also: #data_fields)
All data fields in this section.
- #content_section? ⇒ Boolean
-
#initialize(raw_doc = {}) ⇒ Section
constructor
A new instance of Section.
- #split_section? ⇒ Boolean
Methods included from Concerns::SnakeCamelAccess
#method_missing, #respond_to_missing?
Methods included from Common::GraphQL::Model::AsInput
Methods included from Common::GraphQL::Model::Diffable
Constructor Details
#initialize(raw_doc = {}) ⇒ Section
Returns a new instance of Section.
17 18 19 20 21 |
# File 'lib/ecoportal/api/graphql/base/page/section.rb', line 17 def initialize(raw_doc = {}) raw_doc = raw_doc.dup if raw_doc.is_a?(Hash) raw_doc['type'] ||= raw_doc['__typename'] if raw_doc.is_a?(Hash) super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ecoportal::API::GraphQL::Concerns::SnakeCamelAccess
Instance Method Details
#components ⇒ Object Also known as: data_fields
All data fields in this section. ContentSection → dataFields SplitSection → leftDataFields + rightDataFields (merged)
26 27 28 29 30 31 |
# File 'lib/ecoportal/api/graphql/base/page/section.rb', line 26 def components all = (doc['dataFields'] || []) + (doc['leftDataFields'] || []) + (doc['rightDataFields'] || []) DataField::Collection.from_doc(all) end |
#content_section? ⇒ Boolean
36 37 38 |
# File 'lib/ecoportal/api/graphql/base/page/section.rb', line 36 def content_section? type.to_s == 'ContentSection' end |
#split_section? ⇒ Boolean
40 41 42 |
# File 'lib/ecoportal/api/graphql/base/page/section.rb', line 40 def split_section? type.to_s == 'SplitSection' end |