Class: Lookout::Stub::Method
Direct Known Subclasses
Defined Under Namespace
Instance Method Summary collapse
- #call(*args, &block) ⇒ Object
- #define ⇒ Object
- #each(*values) ⇒ Object
-
#initialize(object, method, &body) ⇒ Method
constructor
A new instance of Method.
- #undefine ⇒ Object
- #yield(*values) ⇒ Object
Constructor Details
#initialize(object, method, &body) ⇒ Method
Returns a new instance of Method.
32 33 34 35 36 |
# File 'lib/lookout/stub/method.rb', line 32 def initialize(object, method, &body) @object, @method, @body = object, method.to_sym, body || Nil @yield = nil @defined = false end |
Instance Method Details
#call(*args, &block) ⇒ Object
55 56 57 58 |
# File 'lib/lookout/stub/method.rb', line 55 def call(*args, &block) @yield.call(&block) if @yield and block @body.call(*args) end |
#define ⇒ Object
48 49 50 51 52 53 |
# File 'lib/lookout/stub/method.rb', line 48 def define return self if @defined define! @defined = true self end |
#each(*values) ⇒ Object
43 44 45 46 |
# File 'lib/lookout/stub/method.rb', line 43 def each(*values) @yield = Each.new(*values) self end |
#undefine ⇒ Object
60 61 62 63 64 65 |
# File 'lib/lookout/stub/method.rb', line 60 def undefine return self unless @defined undefine! @defined = false self end |
#yield(*values) ⇒ Object
38 39 40 41 |
# File 'lib/lookout/stub/method.rb', line 38 def yield(*values) @yield = Values.new(*values) self end |