Class: Yieldable::Mixin
- Inherits:
-
Module
- Object
- Module
- Yieldable::Mixin
- Defined in:
- lib/yieldable.rb
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#once ⇒ Object
readonly
Returns the value of attribute once.
-
#proc ⇒ Object
Returns the value of attribute proc.
Instance Method Summary collapse
- #append_features(base) ⇒ Object
-
#extend_object(base) ⇒ Object
Hook to invoke on ‘extend Yieldable`.
-
#initialize(method_name = :call, once: true) ⇒ Mixin
constructor
A new instance of Mixin.
- #prepend_features(base) ⇒ Object
Constructor Details
#initialize(method_name = :call, once: true) ⇒ Mixin
Returns a new instance of Mixin.
109 110 111 112 113 114 |
# File 'lib/yieldable.rb', line 109 def initialize(method_name = :call, once: true) @method_name = method_name @once = once @proc = nil super() end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
106 107 108 |
# File 'lib/yieldable.rb', line 106 def method_name @method_name end |
#once ⇒ Object (readonly)
Returns the value of attribute once.
106 107 108 |
# File 'lib/yieldable.rb', line 106 def once @once end |
#proc ⇒ Object
Returns the value of attribute proc.
107 108 109 |
# File 'lib/yieldable.rb', line 107 def proc @proc end |
Instance Method Details
#append_features(base) ⇒ Object
132 133 134 135 136 |
# File 'lib/yieldable.rb', line 132 def append_features(base) return unless write_once_in_constant(base) base.include InstanceMethodsMixin super end |
#extend_object(base) ⇒ Object
Hook to invoke on ‘extend Yieldable`.
118 119 120 121 122 123 124 |
# File 'lib/yieldable.rb', line 118 def extend_object(base) return unless write_once_in_constant(base) base.extend(ToProcReader) unless base.singleton_class.method_defined?(:to_proc) base.extend(Inheritance) if base.singleton_class.method_defined?(@method_name) base.extend(WaitMethodDefinition) if wait_method_definition? super end |
#prepend_features(base) ⇒ Object
126 127 128 129 130 |
# File 'lib/yieldable.rb', line 126 def prepend_features(base) return unless write_once_in_constant(base) base.prepend InstanceMethodsMixin super end |