Class: RKit::Override::Base
Defined Under Namespace
Modules: Nodef
Instance Attribute Summary collapse
-
#method ⇒ Object
Returns the value of attribute method.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
Class Method Summary collapse
Instance Method Summary collapse
- #__newdef__ ⇒ Object
- #__olddef__ ⇒ Object
-
#initialize(method_name, method:, pattern:, pattern_args:, receiver:) ⇒ Base
constructor
A new instance of Base.
- #override ⇒ Object
Constructor Details
#initialize(method_name, method:, pattern:, pattern_args:, receiver:) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 |
# File 'lib/r_kit/override/base.rb', line 10 def initialize method_name, method:, pattern:, pattern_args:, receiver:; @method_name = method_name @method = method @pattern = RKit::Override::Pattern.build(pattern, *pattern_args) @receiver = receiver end |
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/r_kit/override/base.rb', line 8 def method @method end |
#method_name ⇒ Object
Returns the value of attribute method_name.
8 9 10 |
# File 'lib/r_kit/override/base.rb', line 8 def method_name @method_name end |
#pattern ⇒ Object
Returns the value of attribute pattern.
8 9 10 |
# File 'lib/r_kit/override/base.rb', line 8 def pattern @pattern end |
#receiver ⇒ Object
Returns the value of attribute receiver.
8 9 10 |
# File 'lib/r_kit/override/base.rb', line 8 def receiver @receiver end |
Class Method Details
.override(*args) ⇒ Object
3 4 5 |
# File 'lib/r_kit/override/base.rb', line 3 def self.override *args new(*args).override end |
Instance Method Details
#__newdef__ ⇒ Object
61 62 63 |
# File 'lib/r_kit/override/base.rb', line 61 def __newdef__ method end |
#__olddef__ ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/r_kit/override/base.rb', line 51 def __olddef__ __olddef__ = receiver.instance_method(method_name) proc do |*args, &block| __olddef__.bind(self).call(*args, &block) end rescue NameError Nodef.__nodef__(method_name) end |
#override ⇒ Object
17 18 19 20 |
# File 'lib/r_kit/override/base.rb', line 17 def override override_method # TODO: hook_method end |