Sha256: 110406fb9c5b0312dd3ad2e6887d1a56601bc110efe49d8375670cca249ccfc0
Contents?: true
Size: 893 Bytes
Versions: 5
Compression:
Stored size: 893 Bytes
Contents
require 'active_support' class LHS::Collection < LHS::Proxy module InternalCollection extend ActiveSupport::Concern # The internal collection class that includes enumerable # and insures to return LHS::Items in case of iterating items class Collection include Enumerable attr_accessor :raw delegate :last, :sample, :[], :present?, :blank?, :empty?, to: :raw def initialize(raw, parent, record) self.raw = raw @parent = parent @record = record end def each(&_block) raw.each do |item| if item.is_a? Hash yield cast_item(item) else yield item end end end private def cast_item(item) data = LHS::Data.new(item, @parent, @record) return @record.new(data) if @record data end end end end
Version data entries
5 entries across 5 versions & 1 rubygems