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.31.0 lib/recurly/resource.rb
recurly-4.30.0 lib/recurly/resource.rb
recurly-4.29.0 lib/recurly/resource.rb
recurly-3.25.0 lib/recurly/resource.rb
recurly-4.28.0 lib/recurly/resource.rb
recurly-4.27.0 lib/recurly/resource.rb
recurly-3.24.0 lib/recurly/resource.rb
recurly-3.23.0 lib/recurly/resource.rb
recurly-4.26.0 lib/recurly/resource.rb
recurly-4.25.0 lib/recurly/resource.rb
recurly-4.24.0 lib/recurly/resource.rb
recurly-4.23.0 lib/recurly/resource.rb
recurly-4.22.0 lib/recurly/resource.rb
recurly-3.22.0 lib/recurly/resource.rb
recurly-4.21.1 lib/recurly/resource.rb
recurly-4.21.0 lib/recurly/resource.rb
recurly-4.20.0 lib/recurly/resource.rb
recurly-3.21.0 lib/recurly/resource.rb
recurly-4.19.0 lib/recurly/resource.rb
recurly-3.20.0 lib/recurly/resource.rb