Class: Compendium::ResultSet
- Inherits:
-
Object
- Object
- Compendium::ResultSet
- Defined in:
- lib/compendium/result_set.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
(also: #all)
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(records) ⇒ ResultSet
constructor
A new instance of ResultSet.
- #keys ⇒ Object
Constructor Details
#initialize(records) ⇒ ResultSet
Returns a new instance of ResultSet.
10 11 12 13 14 |
# File 'lib/compendium/result_set.rb', line 10 def initialize(records) @records = records.map do |r| r.respond_to?(:with_indifferent_access) ? r.with_indifferent_access : r end end |
Instance Attribute Details
#records ⇒ Object (readonly) Also known as: all
Returns the value of attribute records.
7 8 9 |
# File 'lib/compendium/result_set.rb', line 7 def records @records end |
Instance Method Details
#as_json(options = {}) ⇒ Object
20 21 22 |
# File 'lib/compendium/result_set.rb', line 20 def as_json( = {}) records.map{ |r| r.except(*[:except]) } end |
#keys ⇒ Object
16 17 18 |
# File 'lib/compendium/result_set.rb', line 16 def keys records.is_a?(Array) ? first.keys : records.keys end |