Class: Rydux::State

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/rydux/state.rb

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ State

Returns a new instance of State.



5
6
7
8
# File 'lib/rydux/state.rb', line 5

def initialize(state)
  super(state)
  @structure = state.clone
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rydux/state.rb', line 18

def method_missing(method)
  if self[method].is_a? Hash
    self[method] = self.class.new(self[method])
  else
    self[method]
  end
end

Instance Method Details

#inspectObject



14
15
16
# File 'lib/rydux/state.rb', line 14

def inspect
  @structure.inspect
end

#to_sObject



10
11
12
# File 'lib/rydux/state.rb', line 10

def to_s
  @structure.inspect
end