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.
115 116 117 |
# File 'lib/hal_interpretation.rb', line 115 def extractor_for(attr_name) extractors.find {|it| it.attr == attr_name } end |
#extractors ⇒ Object
Returns collection of attribute extractors.
110 111 112 |
# File 'lib/hal_interpretation.rb', line 110 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
99 100 101 102 103 104 105 |
# File 'lib/hal_interpretation.rb', line 99 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 |