Class: Locomotive::Liquid::Drops::Base
- Inherits:
-
Liquid::Drop
- Object
- Liquid::Drop
- Locomotive::Liquid::Drops::Base
- Defined in:
- lib/locomotive/liquid/drops/base.rb
Direct Known Subclasses
Constant Summary collapse
- @@forbidden_attributes =
%w{_id _version _index}
Class Method Summary collapse
-
.liquify(*records, &block) ⇒ Object
converts an array of records to an array of liquid drops.
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(source) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(source) ⇒ Base
Returns a new instance of Base.
9 10 11 |
# File 'lib/locomotive/liquid/drops/base.rb', line 9 def initialize(source) @_source = source end |
Class Method Details
.liquify(*records, &block) ⇒ Object
converts an array of records to an array of liquid drops
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/locomotive/liquid/drops/base.rb', line 18 def self.liquify(*records, &block) i = -1 records = records.inject [] do |all, r| i+=1 attrs = (block && block.arity == 1) ? [r] : [r, i] all << (block ? block.call(*attrs) : r.to_liquid) all end records.compact! records end |
Instance Method Details
#id ⇒ Object
13 14 15 |
# File 'lib/locomotive/liquid/drops/base.rb', line 13 def id (@_source.respond_to?(:id) ? @_source.id : nil) || 'new' end |