module ElvantoAPI::Resource

Attributes

attributes[RW]

Public Class Methods

included(base) click to toggle source
# File lib/elvanto/resources/resource.rb, line 37
def self.included(base)
  base.extend ClassMethods
end
new(attributes = {}) click to toggle source

@params [Hash] attributes List of object's attributes

# File lib/elvanto/resources/resource.rb, line 13
def initialize(attributes = {})
  @attributes = Utils.indifferent_read_access attributes
end

Public Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/elvanto/resources/resource.rb, line 29
def method_missing(method, *args, &block)
  if @attributes.has_key?(method.to_s)
    return @attributes[method.to_s]
  end

  super method, *args, &block
end
query_member(method, options={}) click to toggle source

@params [Symbol] method The name of the method to call @params [Hash] options The parameters to pass to the method. @return [Object] The response from the API method.

# File lib/elvanto/resources/resource.rb, line 25
def query_member(method, options={})
  self.class.query_member(method, options.merge({id: id}))
end
reload() click to toggle source

@return [Object] New copy of the object with updated attributes

# File lib/elvanto/resources/resource.rb, line 18
def reload
  self.class.find({id: id})
end