Class: HalClient::RepresentationSet
- Inherits:
-
Object
- Object
- HalClient::RepresentationSet
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/hal_client/representation_set.rb
Overview
A collection HAL representations
Instance Method Summary collapse
-
#initialize(reprs) ⇒ RepresentationSet
constructor
A new instance of RepresentationSet.
-
#related(link_rel, options = {}) ⇒ Object
Returns representations of resources related via the specified link rel or the specified default value.
Constructor Details
#initialize(reprs) ⇒ RepresentationSet
Returns a new instance of RepresentationSet.
8 9 10 |
# File 'lib/hal_client/representation_set.rb', line 8 def initialize(reprs) @reprs = reprs end |
Instance Method Details
#related(link_rel, options = {}) ⇒ Object
Returns representations of resources related via the specified
link rel or the specified default value.
name_or_rel - The name of property or link rel of interest options - optional keys and values with which to expand any
templated links that are encountered
default_proc - an option proc that will be called with name
to produce default value if the specified property or link does not
exist
Raises KeyError if the specified link does not exist
and no default_proc is provided.
26 27 28 |
# File 'lib/hal_client/representation_set.rb', line 26 def (link_rel, ={}) RepresentationSet.new flat_map{|it| it.(link_rel, ){[]}.to_a } end |