Module: RestModel::Source::Retriever

Included in:
RestModel
Defined in:
lib/rest_model/source/retriever.rb

Instance Method Summary collapse

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, options = {})
  entries = prepare_entries(input, options)

  if entries.any? {|e| !e.kind_of?(Hash)}
    fail "invalid input" if options[:fail]
    return []
  end

  entries.collect do |item|
    handle_item(item.with_indifferent_access, options)
  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, options = {})
  from_source(input, options.merge(fail: true))
end