Sha256: c9d9e6c7dc835dd8be496b8ea5df13712f61baaa1c331dc8aecc3bcae14d7b47

Contents?: true

Size: 484 Bytes

Versions: 1

Compression:

Stored size: 484 Bytes

Contents

module GoogleAjax
  class Base < OpenStruct
    def [](key)
      send(key)
    end

    def []=(key, value)
      send("#{key}=", value)
    end

    def self.remap(h)
      define_method(:initialize) do |arg|
        super(arg)
        h.each do |key, klass|
          case self[key]
          when Array
            self[key] = self[key].map(&klass.method(:new))
          when Hash
            self[key] = klass.new(self[key])
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
googleajax-0.2.0 lib/googleajax/base.rb