Class: Locomotive::Steam::Liquid::Drops::SectionBlock
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Locomotive::Steam::Liquid::Drops::SectionBlock
- Defined in:
- lib/locomotive/steam/liquid/drops/section_block.rb
Overview
Section block drop
Instance Method Summary collapse
- #depth ⇒ Object
- #has_leaves? ⇒ Boolean
- #id ⇒ Object
-
#initialize(section, block, index) ⇒ SectionBlock
constructor
A new instance of SectionBlock.
- #leaves ⇒ Object
- #locomotive_attributes ⇒ Object
- #settings ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(section, block, index) ⇒ SectionBlock
Returns a new instance of SectionBlock.
9 10 11 12 13 14 15 16 17 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 9 def initialize(section, block, index) @section = section @block = block || { 'settings' => {} } @index = index @leaves = [] @definition = section.definition['blocks'].find do |block| block['type'] == type end || {} end |
Instance Method Details
#depth ⇒ Object
27 28 29 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 27 def depth @block['depth'].presence || 0 end |
#has_leaves? ⇒ Boolean
35 36 37 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 35 def has_leaves? leaves.size > 0 end |
#id ⇒ Object
19 20 21 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 19 def id @block['id'] || @index end |
#leaves ⇒ Object
31 32 33 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 31 def leaves @leaves end |
#locomotive_attributes ⇒ Object
46 47 48 49 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 46 def locomotive_attributes value = "section-#{@context['section'].id}-block-#{id}" %(data-locomotive-block="#{value}") end |
#settings ⇒ Object
39 40 41 42 43 44 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 39 def settings @content_proxy ||= SectionContentProxy.new( @block['settings'] || {}, @definition['settings'] || [] ) end |
#type ⇒ Object
23 24 25 |
# File 'lib/locomotive/steam/liquid/drops/section_block.rb', line 23 def type @block['type'] end |