Sha256: 768f9db327867e908a3d60e328f3fa9d8a34a4d79f7b28034475cbee3892ed92

Contents?: true

Size: 1.03 KB

Versions: 87

Compression:

Stored size: 1.03 KB

Contents

module Recurly
  # This class represents an object as it exists on the
  # Recurly servers. It is generated from a response. If you wish to
  # update or change a resource, you need to send a request to the server
  # and get a new Resource.
  class Resource
    extend Schema::SchemaFactory
    extend Schema::ResourceCaster
    include Schema::SchemaValidator

    attr_reader :attributes

    def requires_client?
      false
    end

    def ==(other_resource)
      self.attributes == other_resource.attributes
    end

    # Hide instance variables to keep from accidental logging
    def inspect
      "#<#{self.class.name}:#{object_id}} @attributes=#{attributes}>"
    end

    def to_s
      self.inspect
    end

    def to_json
      raise NoMethodError, "to_json is not implemented for Resources. Please use Resource#attributes"
    end

    def get_response
      @response
    end

    protected

    def schema
      self.class.schema
    end

    def initialize(attributes = {})
      @attributes = attributes.clone
    end
  end
end

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
recurly-3.18.1 lib/recurly/resource.rb
recurly-3.18.0 lib/recurly/resource.rb
recurly-3.17.0 lib/recurly/resource.rb
recurly-3.16.0 lib/recurly/resource.rb
recurly-3.15.0 lib/recurly/resource.rb
recurly-3.14.0 lib/recurly/resource.rb
recurly-3.13.0 lib/recurly/resource.rb
recurly-3.12.0 lib/recurly/resource.rb
recurly-3.11.0 lib/recurly/resource.rb
recurly-3.10.0 lib/recurly/resource.rb
recurly-3.9.0 lib/recurly/resource.rb
recurly-3.8.0 lib/recurly/resource.rb
recurly-3.7.0 lib/recurly/resource.rb
recurly-3.6.0 lib/recurly/resource.rb
recurly-3.5.0 lib/recurly/resource.rb
recurly-3.4.1 lib/recurly/resource.rb
recurly-3.4.0 lib/recurly/resource.rb
recurly-3.3.1 lib/recurly/resource.rb
recurly-3.3.0 lib/recurly/resource.rb
recurly-3.2.2 lib/recurly/resource.rb