Class: Simmer::Util::RecordSet
- Inherits:
-
Object
- Object
- Simmer::Util::RecordSet
- Extended by:
- Forwardable
- Defined in:
- lib/simmer/util/record_set.rb
Overview
A less-strict comparable collection of Record instances. It does not depend on Record ordering.
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #&(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(records = []) ⇒ RecordSet
constructor
A new instance of RecordSet.
- #keys ⇒ Object
- #to_h ⇒ Object
Constructor Details
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
21 22 23 |
# File 'lib/simmer/util/record_set.rb', line 21 def records @records end |
Instance Method Details
#&(other) ⇒ Object
44 45 46 |
# File 'lib/simmer/util/record_set.rb', line 44 def &(other) self.class.new(records & other.records) end |
#==(other) ⇒ Object Also known as: eql?
29 30 31 |
# File 'lib/simmer/util/record_set.rb', line 29 def ==(other) other.instance_of?(self.class) && records == other.records end |
#keys ⇒ Object
40 41 42 |
# File 'lib/simmer/util/record_set.rb', line 40 def keys records.flat_map(&:keys) end |
#to_h ⇒ Object
34 35 36 37 38 |
# File 'lib/simmer/util/record_set.rb', line 34 def to_h { 'records' => records.map(&:to_h) } end |