Module: HalInterpretation::ClassMethods
- Defined in:
- lib/hal_interpretation.rb
Instance Method Summary collapse
-
#extractor_for(attr_name) ⇒ Object
Returns the attribute extractor for the specified attribute.
-
#extractors ⇒ Object
Returns collection of attribute extractors.
-
#new_from_json(json) ⇒ Object
Returns new interpreter for the provided JSON document.
Instance Method Details
#extractor_for(attr_name) ⇒ Object
Returns the attribute extractor for the specified attribute.
123 124 125 |
# File 'lib/hal_interpretation.rb', line 123 def extractor_for(attr_name) extractors.find {|it| it.attr == attr_name } end |
#extractors ⇒ Object
Returns collection of attribute extractors.
118 119 120 |
# File 'lib/hal_interpretation.rb', line 118 def extractors @extractors ||= [] end |
#new_from_json(json) ⇒ Object
Returns new interpreter for the provided JSON document.
Raises HalInterpretation::InvalidRepresentationError if the
provided JSON document is not parseable
107 108 109 110 111 112 113 |
# File 'lib/hal_interpretation.rb', line 107 def new_from_json(json) self.new HalClient::Representation.new(parsed_json: MultiJson.load(json)), location: "/" rescue MultiJson::ParseError => err fail InvalidRepresentationError, "Parse error: " + err. end |