Sha256: 129578b4584932c59fbebe8846354866e446d1d40c80364d563c16ebdb3176e5
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 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 ==(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pluck_map-0.5.0 | lib/pluck_map/attributes.rb |