Module: Braintree::BaseModule::Methods

Included in:
Braintree::BaseModule
Defined in:
lib/braintree/base_module.rb

Instance Method Summary collapse

Instance Method Details

#copy_instance_variables_from_object(object) ⇒ Object



13
14
15
16
17
# File 'lib/braintree/base_module.rb', line 13

def copy_instance_variables_from_object(object)
  object.instance_variables.each do |ivar|
    instance_variable_set ivar, object.instance_variable_get(ivar)
  end
end

#return_object_or_raise(object_to_return) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/braintree/base_module.rb', line 4

def return_object_or_raise(object_to_return)
  result = yield
  if result.success?
    result.send object_to_return
  else
    raise ValidationsFailed.new(result)
  end
end

#set_instance_variables_from_hash(hash) ⇒ Object



19
20
21
22
23
# File 'lib/braintree/base_module.rb', line 19

def set_instance_variables_from_hash(hash)
  hash.each do |key, value|
    instance_variable_set "@#{key}", value
  end
end

#singleton_classObject



25
26
27
# File 'lib/braintree/base_module.rb', line 25

def singleton_class
  class << self; self; end
end