Module: CopyMethod::Integration
- Defined in:
- lib/copy_method/integration.rb
Instance Method Summary collapse
- #copy_method(name, from: nil, to: nil, remove: false, singleton: false) ⇒ Object
- #copy_singleton_method(name, **kwargs) ⇒ Object
- #move_method(name, **kwargs) ⇒ Object
- #move_singleton_method(name, **kwargs) ⇒ Object
Instance Method Details
#copy_method(name, from: nil, to: nil, remove: false, singleton: false) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/copy_method/integration.rb', line 3 def copy_method(name, from: nil, to: nil, remove: false, singleton: false) if from.nil? && to.nil? raise ArgumentError, "must specify either `from` or `to` keywords" end from = self if from.nil? to = self if to.nil? CopyMethod.copy_method name, from: from, to: to, remove: remove, singleton: singleton end |
#copy_singleton_method(name, **kwargs) ⇒ Object
20 21 22 23 24 |
# File 'lib/copy_method/integration.rb', line 20 def copy_singleton_method(name, **kwargs) kwargs[:singleton] = true copy_method name, **kwargs end |
#move_method(name, **kwargs) ⇒ Object
14 15 16 17 18 |
# File 'lib/copy_method/integration.rb', line 14 def move_method(name, **kwargs) kwargs[:remove] = true copy_method name **kwargs end |
#move_singleton_method(name, **kwargs) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/copy_method/integration.rb', line 26 def move_singleton_method(name, **kwargs) kwargs[:singleton] = true kwargs[:remove] = true copy_method name, **kwargs end |