Module: DaisybillApi::Ext::CRUD::Index::ClassMethods
- Defined in:
- lib/daisybill_api/ext/crud/index.rb
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Retrieves a list of records.
Instance Method Details
#all(options = {}) ⇒ Object
Retrieves a list of records
@patients = DaisybillApi::Models::Patient.all(billing_provider_id: 2)
# => #<DaisybillApi::Ext::PageableCollection>
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/daisybill_api/ext/crud/index.rb', line 13 def all( = {}) id = [@prefix_property] if [:path] c = client(:get, .delete(:path), ) else c = client(:get, index_path(id), ) end if c.success? collection_key = [:collection_key] || plural_key.to_s DaisybillApi::Ext::PageableCollection.new( c.response[collection_key].map { |attributes| instance = new(attributes) instance.send("#{prefix_property}=", id) if path_prefix? instance }, { headers: c.headers, params: , resource_class: self } ) else DaisybillApi::Ext::PageableCollection.new([]) end end |