class SalesforceOrm::ObjectBase
Public Class Methods
find(*args)
click to toggle source
# File lib/salesforce-orm/object_base.rb, line 38 def find(*args) find_by_id(*args) end
method_missing(method, *args, &block)
click to toggle source
# File lib/salesforce-orm/object_base.rb, line 42 def method_missing(method, *args, &block) regex = /^find_by_(.+)$/ if method =~ regex fields = method.to_s.match(regex).captures[0].split('_and_') condition = {} fields.each_with_index do |field, index| condition[field.to_sym] = args[index] end where(condition).first end end
orm()
click to toggle source
# File lib/salesforce-orm/object_base.rb, line 54 def orm Base.new(self) end
Public Instance Methods
inspect()
click to toggle source
# File lib/salesforce-orm/object_base.rb, line 72 def inspect to_h end
marshal_dump()
click to toggle source
marshal_dump
and marshal_load
is a fix for unable to cache object of this class. This is a temporary solution. Once Restforce::Mash fix this issue, we'll revert this change
# File lib/salesforce-orm/object_base.rb, line 79 def marshal_dump h = to_h if h[:attributes] h[:attributes] = h[:attributes].clone h[:attributes].instance_variable_set(:@client, nil) end if h[:original_object] h[:original_object] = h[:original_object].clone h[:original_object].instance_variable_set(:@client, nil) if h[:original_object]['attributes'] h[:original_object]['attributes'] = h[:original_object]['attributes'].clone h[:original_object]['attributes'].instance_variable_set(:@client, nil) end end h end
marshal_load(data)
click to toggle source
Calls superclass method
# File lib/salesforce-orm/object_base.rb, line 98 def marshal_load(data) result = super(data) attributes.instance_variable_set(:@client, RestforceClient.instance) if attributes original_object.instance_variable_set(:@client, RestforceClient.instance) if original_object original_object.attributes.instance_variable_set(:@client, RestforceClient.instance) if original_object && original_object.attributes result end
to_hash()
click to toggle source
# File lib/salesforce-orm/object_base.rb, line 68 def to_hash to_h end