Class: MethodCallbacks::Method
- Inherits:
-
Object
- Object
- MethodCallbacks::Method
- Extended by:
- Forwardable
- Defined in:
- lib/method_callbacks/method.rb
Constant Summary collapse
- ALIAS_PREFIX =
"__method_callback_alias_to_original"
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #alias ⇒ Object
- #callbacks(type) ⇒ Object
- #execute(type, object) ⇒ Object
-
#initialize(name) ⇒ Method
constructor
A new instance of Method.
Constructor Details
#initialize(name) ⇒ Method
Returns a new instance of Method.
17 18 19 |
# File 'lib/method_callbacks/method.rb', line 17 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/method_callbacks/method.rb', line 12 def name @name end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/method_callbacks/method.rb', line 21 def ==(other) self.name == other.name end |
#alias ⇒ Object
25 26 27 |
# File 'lib/method_callbacks/method.rb', line 25 def alias "#{ALIAS_PREFIX}_#{name}" end |
#callbacks(type) ⇒ Object
29 30 31 32 |
# File 'lib/method_callbacks/method.rb', line 29 def callbacks(type) @_callbacks ||= {} @_callbacks[type] ||= [] end |
#execute(type, object) ⇒ Object
34 35 36 |
# File 'lib/method_callbacks/method.rb', line 34 def execute(type, object) block_given? ? executor(type, object).execute(&Proc.new) : executor(type, object).execute end |