Sha256: 681e432f27471f6c1ff8c61b6f51e142d81f2d53d37565b47e00ab1c4e921873
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
# Code taken from Mephisto sources (http://mephistoblog.com/) module Locomotive module Steam module Liquid module Drops class Base < ::Liquid::Drop @@forbidden_attributes = %w{_id _version _index} def initialize(source) @_source = source end def id (@_source.respond_to?(:id) ? @_source.id : nil) || 'new' end # converts an array of records to an array of liquid drops 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 protected def liquify(*records, &block) self.class.liquify(*records, &block) end def _source @_source end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms_steam-0.1.1 | lib/locomotive/steam/liquid/drops/base.rb |
locomotivecms_steam-0.1.0 | lib/locomotive/steam/liquid/drops/base.rb |