class IronBank::Resource
An Iron Bank RESTful resource.
Attributes
remote[R]
Public Class Methods
new(remote = {})
click to toggle source
# File lib/iron_bank/resource.rb, line 27 def initialize(remote = {}) @remote = remote end
object_name()
click to toggle source
# File lib/iron_bank/resource.rb, line 12 def self.object_name name.split("::").last end
with_cache()
click to toggle source
# File lib/iron_bank/resource.rb, line 20 def self.with_cache include IronBank::Cacheable extend IronBank::Cacheable::ClassMethods end
with_local_records()
click to toggle source
# File lib/iron_bank/resource.rb, line 16 def self.with_local_records extend IronBank::Local end
Public Instance Methods
==(other)
click to toggle source
Two resources are equals if their remote (from Zuora) data are similar
# File lib/iron_bank/resource.rb, line 48 def ==(other) other.is_a?(IronBank::Resource) ? remote == other.remote : false end
id()
click to toggle source
Every Zuora object has an ID, so we can safely declare it for each resource
# File lib/iron_bank/resource.rb, line 33 def id remote[:id] end
inspect()
click to toggle source
# File lib/iron_bank/resource.rb, line 37 def inspect # NOTE: In Ruby, the IDs of objects start from the second bit on the right # but in "value space" (used by the original `inspect` implementation) # they start from the third bit on the right. Hence the bitsfhit operation # here. # https://stackoverflow.com/questions/2818602/in-ruby-why-does-inspect-print-out-some-kind-of-object-id-which-is-different ruby_id = "#{self.class.name}:0x#{(object_id << 1).to_s(16)} id=\"#{id}\"" respond_to?(:name) ? "#<#{ruby_id} name=\"#{name}\">" : "#<#{ruby_id}>" end
reload()
click to toggle source
# File lib/iron_bank/resource.rb, line 52 def reload remove_instance_vars @remote = self.class.find(id).remote self end
remove_instance_vars()
click to toggle source
# File lib/iron_bank/resource.rb, line 58 def remove_instance_vars # Substract predefined variables from the instance variables (instance_variables - [:@remote]).each do |var| remove_instance_variable(:"#{var}") end end