Module: MultiMethods::InstanceMethods
- Defined in:
- lib/multi_methods.rb
Instance Method Summary collapse
- #defmethod(method_name, dispatch_value, default_dispatch_fn) ⇒ Object
- #defmulti(method_name, default_dispatch_fn = nil) ⇒ Object
- #defmulti_local(&block) ⇒ Object
Instance Method Details
#defmethod(method_name, dispatch_value, default_dispatch_fn) ⇒ Object
71 72 73 |
# File 'lib/multi_methods.rb', line 71 def defmethod method_name, dispatch_value, default_dispatch_fn self.class.defmethod method_name, dispatch_value, default_dispatch_fn end |
#defmulti(method_name, default_dispatch_fn = nil) ⇒ Object
66 67 68 69 |
# File 'lib/multi_methods.rb', line 66 def defmulti method_name, default_dispatch_fn = nil instance_variable_set( :@added_multi_method, method_name ) self.class.defmulti method_name, default_dispatch_fn end |
#defmulti_local(&block) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/multi_methods.rb', line 54 def defmulti_local &block instance_eval &block #clean up after evaling block instance_eval do method_name = instance_variable_get( :@added_multi_method ) self.class.send(:undef_method, method_name) self.class.send(:remove_instance_variable, ('@' + method_name.to_s).to_sym ) self.send( :remove_instance_variable, :@added_multi_method ) end end |