Class: Lifer::Builder::HTML::FromLiquid::Drops::CollectionsDrop
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Lifer::Builder::HTML::FromLiquid::Drops::CollectionsDrop
- Defined in:
- lib/lifer/builder/html/from_liquid/drops/collections_drop.rb
Overview
This drop allows users to iterate over their Lifer collections in Liquid templates.
Instance Attribute Summary collapse
-
#collections ⇒ Object
Returns the value of attribute collections.
Instance Method Summary collapse
-
#each {|CollectionDrop| ... } ⇒ Object
Allow collections to be iterable in Liquid templates.
-
#initialize ⇒ CollectionsDrop
constructor
A new instance of CollectionsDrop.
-
#liquid_method_missing(arg) ⇒ CollectionDrop, NilClass
Dynamically define Liquid accessors based on the Lifer project’s collection names.
-
#to_a ⇒ Array
Allow collections to be rendered as an array in Liquid templates.
Constructor Details
#initialize ⇒ CollectionsDrop
Returns a new instance of CollectionsDrop.
13 14 15 |
# File 'lib/lifer/builder/html/from_liquid/drops/collections_drop.rb', line 13 def initialize @collections = Lifer.collections.map { CollectionDrop.new _1 } end |
Instance Attribute Details
#collections ⇒ Object
Returns the value of attribute collections.
11 12 13 |
# File 'lib/lifer/builder/html/from_liquid/drops/collections_drop.rb', line 11 def collections @collections end |
Instance Method Details
#each {|CollectionDrop| ... } ⇒ Object
Allow collections to be iterable in Liquid templates.
20 21 22 |
# File 'lib/lifer/builder/html/from_liquid/drops/collections_drop.rb', line 20 def each(&block) collections.each(&block) end |
#liquid_method_missing(arg) ⇒ CollectionDrop, NilClass
Dynamically define Liquid accessors based on the Lifer project’s collection names.
37 38 39 |
# File 'lib/lifer/builder/html/from_liquid/drops/collections_drop.rb', line 37 def liquid_method_missing(arg) collections.detect { arg.to_sym == _1.name } end |
#to_a ⇒ Array
Allow collections to be rendered as an array in Liquid templates.
27 |
# File 'lib/lifer/builder/html/from_liquid/drops/collections_drop.rb', line 27 def to_a = @collections |