Class: Hyperclient::Attributes
- Inherits:
-
Collection
- Object
- Collection
- Hyperclient::Attributes
- Defined in:
- lib/hyperclient/attributes.rb
Overview
A wrapper class to easily acces the attributes in a Resource.
Constant Summary collapse
- RESERVED_PROPERTIES =
[/^_links$/, /^_embedded$/].freeze
Instance Method Summary collapse
-
#initialize(representation) ⇒ Attributes
constructor
Initializes the Attributes of a Resource.
Methods inherited from Collection
#[], #each, #fetch, #include?, #method_missing, #respond_to_missing?, #to_h, #to_s
Constructor Details
#initialize(representation) ⇒ Attributes
Initializes the Attributes of a Resource.
16 17 18 19 20 21 22 |
# File 'lib/hyperclient/attributes.rb', line 16 def initialize(representation) @collection = if representation.is_a?(Hash) representation.delete_if { |key, _value| RESERVED_PROPERTIES.any? { |p| p.match(key) } } else representation end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hyperclient::Collection