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.
117 118 119 |
# File 'lib/hal_interpretation.rb', line 117 def extractor_for(attr_name) extractors.find {|it| it.attr == attr_name } end |
#extractors ⇒ Object
Returns collection of attribute extractors.
112 113 114 |
# File 'lib/hal_interpretation.rb', line 112 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
101 102 103 104 105 106 107 |
# File 'lib/hal_interpretation.rb', line 101 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 |