Module: NCore::All::ClassMethods
- Defined in:
- lib/ncore/methods/all.rb
Instance Method Summary collapse
Instance Method Details
#all(params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/ncore/methods/all.rb', line 6 def all(params={}) params = parse_request_params(params) parsed, creds = request(:get, resource_path, params) if parsed[:errors].any? raise module_parent::QueryError, parsed[:errors] end Collection.new.tap do |coll| coll. = parsed[:metadata] parsed[:data].each do |hash| coll << factory({data: hash, metadata: parsed[:metadata]}, creds) end end end |
#first(params = {}) ⇒ Object
20 21 22 23 |
# File 'lib/ncore/methods/all.rb', line 20 def first(params={}) params = params.with_indifferent_access.merge(max_results: 1) all(params).first end |