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-4.18.0 lib/recurly/resource.rb
recurly-4.17.0 lib/recurly/resource.rb
recurly-3.19.0 lib/recurly/resource.rb
recurly-4.15.0 lib/recurly/resource.rb
recurly-4.14.0 lib/recurly/resource.rb
recurly-4.13.0 lib/recurly/resource.rb
recurly-4.12.0 lib/recurly/resource.rb
recurly-4.11.0 lib/recurly/resource.rb
recurly-4.10.0 lib/recurly/resource.rb
recurly-4.9.0 lib/recurly/resource.rb
recurly-4.8.0 lib/recurly/resource.rb
recurly-4.7.0 lib/recurly/resource.rb
recurly-4.6.0 lib/recurly/resource.rb
recurly-4.5.0 lib/recurly/resource.rb
recurly-4.4.0 lib/recurly/resource.rb
recurly-4.3.0 lib/recurly/resource.rb
recurly-4.2.0 lib/recurly/resource.rb
recurly-4.1.0 lib/recurly/resource.rb
recurly-4.0.1 lib/recurly/resource.rb
recurly-4.0.0 lib/recurly/resource.rb