Class: Taksi::Components::Skeleton
- Inherits:
-
Object
- Object
- Taksi::Components::Skeleton
- Defined in:
- lib/taksi/components/skeleton.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #as_json ⇒ Object
- #dynamic? ⇒ Boolean
- #fields ⇒ Object
- #id ⇒ Object
-
#initialize(parent, name, &block) ⇒ Skeleton
constructor
A new instance of Skeleton.
Constructor Details
#initialize(parent, name, &block) ⇒ Skeleton
Returns a new instance of Skeleton.
8 9 10 11 12 13 14 15 |
# File 'lib/taksi/components/skeleton.rb', line 8 def initialize(parent, name, &block) @parent = parent @name = name raise 'To build a component you need to provide a `content` block' unless block_given? @content = ::Taksi::Components::Field.new(self, :content, &block) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/taksi/components/skeleton.rb', line 6 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/taksi/components/skeleton.rb', line 6 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/taksi/components/skeleton.rb', line 6 def parent @parent end |
Instance Method Details
#as_json ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/taksi/components/skeleton.rb', line 29 def as_json { name: name, identifier: id, requires_data: dynamic? }.tap do |json| json.merge!(content.as_json) end end |
#dynamic? ⇒ Boolean
25 26 27 |
# File 'lib/taksi/components/skeleton.rb', line 25 def dynamic? @content.dynamic? end |
#fields ⇒ Object
21 22 23 |
# File 'lib/taksi/components/skeleton.rb', line 21 def fields content.fields end |
#id ⇒ Object
17 18 19 |
# File 'lib/taksi/components/skeleton.rb', line 17 def id parent.id_of(self) end |