Class: CabezaDeTermo::JsonSpec::AccessorsChain

Inherits:
Object
  • Object
show all
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

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

#accessorsObject



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_sObject



22
23
24
# File 'lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb', line 22

def to_s()
	accessors.join('.')
end