Class: Quarry::Mock
Overview
Mock
Defined Under Namespace
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
- #__table__ ⇒ Object
-
#initialize ⇒ Mock
constructor
A new instance of Mock.
-
#method_missing(meth, *args, &block) ⇒ Object
TODO: Ruby has retry, but I need continue!.
Constructor Details
#initialize ⇒ Mock
Returns a new instance of Mock.
8 9 10 11 |
# File 'lib/quarry/mock.rb', line 8 def initialize super() @table = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
TODO: Ruby has retry, but I need continue!
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/quarry/mock.rb', line 17 def method_missing(meth, *args, &block) table = @table interface = [meth, args, block_given?] table[interface] = nil define_method(meth) do |*args| result = super result.assert == table[interface] return result end Setter.new(table, interface) end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
6 7 8 |
# File 'lib/quarry/mock.rb', line 6 def object @object end |
Instance Method Details
#__table__ ⇒ Object
14 |
# File 'lib/quarry/mock.rb', line 14 def __table__ ; @table ; end |