Module: RestModel::Source::Retriever
- Included in:
- RestModel
- Defined in:
- lib/rest_model/source/retriever.rb
Instance Method Summary collapse
- #from_source(input, options = {}) ⇒ Object (also: #parse)
- #from_source!(input, options = {}) ⇒ Object (also: #parse!)
Instance Method Details
#from_source(input, options = {}) ⇒ Object Also known as: parse
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rest_model/source/retriever.rb', line 8 def from_source(input, = {}) entries = prepare_entries(input, ) if entries.any? {|e| !e.kind_of?(Hash)} fail "invalid input" if [:fail] return [] end entries.collect do |item| handle_item(item.with_indifferent_access, ) end end |
#from_source!(input, options = {}) ⇒ Object Also known as: parse!
4 5 6 |
# File 'lib/rest_model/source/retriever.rb', line 4 def from_source!(input, = {}) from_source(input, .merge(fail: true)) end |