Method: Pod4::Model.list
- Defined in:
- lib/pod4/model.rb
.list(params = nil) ⇒ Object
Call this to return an array of record information.
What you actually get depends on the interface, but it must include a recognisable record ID in each array element.
For the purposes of Model we assume that we can make an instance out of each array element, and we return an array of instances of the model. Override this method if that is not true for your Interface.
Note that list should ALWAYS return an array, and array elements should always respond to :id – otherwise we raise a Pod4Error.
Note also that while list returns an array of model objects, read has not been run against each object. The data is there, but @model_status == :unknown, and validation has not been run. This is partly for the sake of efficiency, partly to help avoid recursive loops in validation.
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/pod4/model.rb', line 119 def list(params=nil) fail_no_id_fld unless interface.id_fld interface.list(params).map do |ot| key = ot[interface.id_fld]; fail_no_id unless key rec = self.new(key) rec.map_to_model(ot) # seperately, in case model forgot to return self rec end end |