Class: CabezaDeTermo::JsonSpec::AccessorsChain
- Inherits:
-
Object
- Object
- CabezaDeTermo::JsonSpec::AccessorsChain
- Defined in:
- lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb
Overview
Models the chain of accessors to get to a value in a json tree. For instance, something like
[‘users’, ‘[3]’, ‘addresses’, ‘[0]’, ‘street’]
Instance Method Summary collapse
- #accessors ⇒ Object
- #append_accessor(accessor) ⇒ Object
-
#initialize(accessors = ['@']) ⇒ AccessorsChain
constructor
A new instance of AccessorsChain.
- #to_s ⇒ Object
Constructor Details
#initialize(accessors = ['@']) ⇒ AccessorsChain
Returns a new instance of AccessorsChain.
10 11 12 |
# File 'lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb', line 10 def initialize(accessors = ['@']) @accessors = accessors end |
Instance Method Details
#accessors ⇒ Object
14 15 16 |
# File 'lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb', line 14 def accessors() @accessors end |
#append_accessor(accessor) ⇒ Object
18 19 20 |
# File 'lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb', line 18 def append_accessor(accessor) self.class.new( accessors + [accessor] ) end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb', line 22 def to_s() accessors.join('.') end |