Sha256: 20bb4d8aac0882f4e04c6dd7849b7dafefee292219e3add5afd7edfa576987f7
Contents?: true
Size: 707 Bytes
Versions: 18
Compression:
Stored size: 707 Bytes
Contents
module NCore module All extend ActiveSupport::Concern module ClassMethods 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.metadata = parsed[:metadata] parsed[:data].each do |hash| coll << factory({data: hash, metadata: parsed[:metadata]}, creds) end end end def first(params={}) params = params.with_indifferent_access.merge(max_results: 1) all(params).first end end end end
Version data entries
18 entries across 18 versions & 1 rubygems