Module: Lexile::Model::ClassMethods
- Defined in:
- lib/lexile/model.rb
Instance Method Summary collapse
-
#api_path(path = nil) ⇒ void
api_path This sets the API path so the API collections can use them in an agnostic way.
-
#parse(parsed_json) ⇒ Object
Parses a request.body response into a Lexile::Model objects.
Instance Method Details
#api_path(path = nil) ⇒ void
This method returns an undefined value.
api_path This sets the API path so the API collections can use them in an agnostic way
12 13 14 |
# File 'lib/lexile/model.rb', line 12 def api_path(path = nil) @_api_path ||= path end |
#parse(parsed_json) ⇒ Object
Parses a request.body response into a Lexile::Model objects
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/lexile/model.rb', line 87 def parse( parsed_json ) if parsed_json.has_key?('objects') #this is a multi record and data should contain an array unless parsed_json['objects'].is_a? Array raise Lexile::CannotProcessResponse.new('[:objects] is present in response but it does not contain an Array') end return parsed_json['objects'].map {|array_element| new( array_element ) } else return new( parsed_json ) end end |