Class: Jess::ExtensionAttributes
- Extended by:
- Forwardable
- Defined in:
- lib/jess/extension_attributes.rb
Overview
A Hash-like wrapper around the extension attributes that facilitates easy key/value access.
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(json) ⇒ ExtensionAttributes
constructor
A new instance of ExtensionAttributes.
-
#to_hash ⇒ Object
Explicitly delegate instead of using def_delegators in order to be compatible with awesome_print.
Constructor Details
#initialize(json) ⇒ ExtensionAttributes
Returns a new instance of ExtensionAttributes.
10 11 12 13 14 15 16 |
# File 'lib/jess/extension_attributes.rb', line 10 def initialize(json) super @values = json.each_with_object({}) do |attr, hash| hash[attr["name"]] = attr["value"] end @values.freeze end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jess::Resource
Instance Method Details
#to_hash ⇒ Object
Explicitly delegate instead of using def_delegators in order to be compatible with awesome_print. The original Hash#to_hash method is implemented in C, which means it has an arity of -1. This confuses awesome_print.
22 23 24 |
# File 'lib/jess/extension_attributes.rb', line 22 def to_hash @values.to_hash end |