Module: GameRocket::BaseModule::Methods
- Included in:
- GameRocket::BaseModule
- Defined in:
- lib/gamerocket/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
14 15 16 17 18 |
# File 'lib/gamerocket/base_module.rb', line 14 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
5 6 7 8 9 10 11 12 |
# File 'lib/gamerocket/base_module.rb', line 5 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
20 21 22 23 24 |
# File 'lib/gamerocket/base_module.rb', line 20 def set_instance_variables_from_hash(hash) hash.each do |key, value| instance_variable_set "@#{key}", value end end |
#singleton_class ⇒ Object
26 27 28 |
# File 'lib/gamerocket/base_module.rb', line 26 def singleton_class class <<self; self; end end |