Module: Braintree::BaseModule::Methods
- Included in:
- Braintree::BaseModule
- Defined in:
- lib/braintree/base_module.rb
Instance Method Summary collapse
- #copy_instance_variables_from_object(object) ⇒ Object
- #return_object_or_raise(object_to_return) ⇒ Object
- #set_instance_variables_from_hash(hash) ⇒ Object
- #singleton_class ⇒ Object
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 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/braintree/base_module.rb', line 19 def set_instance_variables_from_hash(hash) hash.each do |key, value| if key == :global_id instance_variable_set "@graphql_id", value elsif key == :android_pay_cards instance_variable_set "@google_pay_cards", value elsif key == :android_pay_card instance_variable_set "@google_pay_card", value elsif key == :android_pay_details instance_variable_set "@google_pay_details", value end instance_variable_set "@#{key}", value end end |
#singleton_class ⇒ Object
35 36 37 |
# File 'lib/braintree/base_module.rb', line 35 def singleton_class class << self; self; end end |