class HalClient::RepresentationSet
A collection HAL representations
Attributes
Public Class Methods
# File lib/hal_client/representation_set.rb, line 10 def initialize(reprs) @reprs = reprs end
Public Instance Methods
Returns the specified `Form`
form_id - the string or symbol id of the form of interest. Default: `“default”`
Raises `KeyError` if the specified form doesn't exist, or if there are duplicates.
# File lib/hal_client/representation_set.rb, line 81 def form(form_id="default") self .map { |r| begin r.form(form_id) rescue KeyError nil end } .compact .tap do |fs| raise KeyError, "Duplicate `#{form_id}` forms exist" if fs.count > 1 end .first end
Patch a `Representation` or `String` to the resource.
NOTE: This only works for a single representation.
data - a `String` or an object that responds to `#to_hal` options - set of options to pass to `HalClient#patch`
# File lib/hal_client/representation_set.rb, line 70 def patch(data, options={}) raise NotImplementedError, "We only patchs to singular resources." if count > 1 first.patch(data, options) end
Post a `Representation` or `String` to the resource.
NOTE: This only works for a single representation.
data - a `String` or an object that responds to `#to_hal` options - set of options to pass to `HalClient#post`
# File lib/hal_client/representation_set.rb, line 48 def post(data, options={}) raise NotImplementedError, "We only posts to singular resources." if count > 1 first.post(data, options) end
Put a `Representation` or `String` to the resource.
NOTE: This only works for a single representation.
data - a `String` or an object that responds to `#to_hal` options - set of options to pass to `HalClient#put`
# File lib/hal_client/representation_set.rb, line 59 def put(data, options={}) raise NotImplementedError, "We only puts to singular resources." if count > 1 first.put(data, options) end