Sha256: 371a87f40176fe96db0eee0e0a98026ad978eaa876d87fa5b1323da6847f09ec

Contents?: true

Size: 437 Bytes

Versions: 2

Compression:

Stored size: 437 Bytes

Contents

require 'ostruct'

module Rydux
  class State < OpenStruct
    def initialize(state)
      state = state.clone
      super(state)
      @structure = state
    end

    def to_s
      @structure.inspect
    end

    def inspect
      @structure.inspect
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rydux-0.9.1 lib/rydux/state.rb
rydux-0.9.0 lib/rydux/state.rb