Sha256: d7916516a19a8a0b55c352a364fb970390c315e150b386f093e1078131df72a6

Contents?: true

Size: 417 Bytes

Versions: 3

Compression:

Stored size: 417 Bytes

Contents

require 'ostruct'

module Rydux
  class State < OpenStruct
    def initialize(state)
      super(state)
      @structure = state.clone
    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

3 entries across 3 versions & 1 rubygems

Version Path
rydux-0.9.4 lib/rydux/state.rb
rydux-0.9.3 lib/rydux/state.rb
rydux-0.9.2 lib/rydux/state.rb