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}
Instance Attribute Summary collapse
-
#_source ⇒ Object
readonly
Returns the value of attribute _source.
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.
11 12 13 |
# File 'lib/locomotive/liquid/drops/base.rb', line 11 def initialize(source) @_source = source end |
Instance Attribute Details
#_source ⇒ Object (readonly)
Returns the value of attribute _source.
9 10 11 |
# File 'lib/locomotive/liquid/drops/base.rb', line 9 def _source @_source end |
Class Method Details
.liquify(*records, &block) ⇒ Object
converts an array of records to an array of liquid drops
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/locomotive/liquid/drops/base.rb', line 20 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
15 16 17 |
# File 'lib/locomotive/liquid/drops/base.rb', line 15 def id (@_source.respond_to?(:id) ? @_source.id : nil) || 'new' end |