Sha256: 1ee0b9e4f77bcca487c941a794712071af0768a88c71009514d8e046d1b27307

Contents?: true

Size: 928 Bytes

Versions: 47

Compression:

Stored size: 928 Bytes

Contents

module RestfulResource
  class OpenObject
    def initialize(attributes = {}, hack_for_activeresource = false)
      @inner_object = OpenStruct.new(attributes)
    end

    def method_missing(method, *args, &block)
      if @inner_object.respond_to?(method)
        @inner_object.send(method, *args, &block)
      else
        super(method)
      end
    end

    def respond_to?(method, include_private = false)
      super || @inner_object.respond_to?(method, include_private)
    end

    def as_json(options=nil)
      @inner_object.send(:table).as_json(options)
    end

    def ==(other)
      @inner_object == other.instance_variable_get(:@inner_object)
    end

    def eql?(other)
      @inner_object.eql?(other.instance_variable_get(:@inner_object))
    end

    def equal?(other)
      @inner_object.equal?(other.instance_variable_get(:@inner_object))
    end

    def hash
      @inner_object.hash
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
restful_resource-0.8.27 lib/restful_resource/open_object.rb
restful_resource-0.8.26 lib/restful_resource/open_object.rb
restful_resource-0.8.25 lib/restful_resource/open_object.rb
restful_resource-0.8.24 lib/restful_resource/open_object.rb
restful_resource-0.8.23 lib/restful_resource/open_object.rb
restful_resource-0.8.22 lib/restful_resource/open_object.rb
restful_resource-0.8.21 lib/restful_resource/open_object.rb