Module: Jsapi::Model::Nestable
- Included in:
- Controller::Parameters, JSON::Object
- Defined in:
- lib/jsapi/model/nestable.rb
Instance Method Summary collapse
-
#[](name) ⇒ Object
Returns the value assigned to
name
. -
#additional_attributes ⇒ Object
Returns a hash containing the additional attributes.
-
#attribute?(name) ⇒ Boolean
Returns
true
ifname
is present, falseotherwise
. -
#attributes ⇒ Object
Returns a hash containing all attributes.
-
#inspect ⇒ Object
:nodoc:.
Instance Method Details
#[](name) ⇒ Object
Returns the value assigned to name
.
7 8 9 |
# File 'lib/jsapi/model/nestable.rb', line 7 def [](name) raw_attributes[name&.to_s]&.value end |
#additional_attributes ⇒ Object
Returns a hash containing the additional attributes.
12 13 14 |
# File 'lib/jsapi/model/nestable.rb', line 12 def additional_attributes raw_additional_attributes.transform_values(&:value) end |
#attribute?(name) ⇒ Boolean
Returns true
if name
is present, false otherwise
.
17 18 19 |
# File 'lib/jsapi/model/nestable.rb', line 17 def attribute?(name) raw_attributes.key?(name&.to_s) end |
#attributes ⇒ Object
Returns a hash containing all attributes.
22 23 24 |
# File 'lib/jsapi/model/nestable.rb', line 22 def attributes raw_attributes.transform_values(&:value) end |
#inspect ⇒ Object
:nodoc:
26 27 28 29 30 31 32 33 |
# File 'lib/jsapi/model/nestable.rb', line 26 def inspect # :nodoc: "#<#{self.class.name} #{ raw_attributes .merge('additional_attributes' => raw_additional_attributes) .map { |k, v| "#{k}: #{v.inspect}" } .join(', ') }>" end |