Sha256: 4360cde6046b36b809a2a2814248be4c5b6b676e55a2dabbe2d070a7cfa5f3c5
Contents?: true
Size: 1.19 KB
Versions: 3
Compression:
Stored size: 1.19 KB
Contents
module PluckMap class Attributes include Enumerable attr_reader :selects def initialize(attributes) @_attributes = attributes.freeze @_attributes_by_id = {} @selects = [] attributes.each do |attribute| attribute.indexes = attribute.selects.map do |select| selects.find_index(select) || begin selects.push(select) selects.length - 1 end end _attributes_by_id[attribute.id] = attribute end _attributes_by_id.freeze end def each(&block) _attributes.each(&block) end def [](index) _attributes[index] end def length _attributes.length end def by_id _attributes_by_id end def will_map? _attributes.any?(&:will_map?) end def ==(other) return false if self.class != other.class _attributes == other.send(:_attributes) end def hash _attributes.hash end def eql?(other) return true if self.equal?(other) return false if self.class != other.class _attributes.eql?(other.send(:_attributes)) end private attr_reader :_attributes, :_attributes_by_id end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pluck_map-0.6.2 | lib/pluck_map/attributes.rb |
pluck_map-0.6.1 | lib/pluck_map/attributes.rb |
pluck_map-0.6.0 | lib/pluck_map/attributes.rb |