Class: Quarry::Stub

Inherits:
Module show all
Defined in:
lib/quarry/stub.rb

Defined Under Namespace

Classes: Delegator, Setter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStub

Returns a new instance of Stub.



7
8
9
10
# File 'lib/quarry/stub.rb', line 7

def initialize
  super()
  @table = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/quarry/stub.rb', line 16

def method_missing(meth, *args, &block)
  table     = @table
  interface = [meth, args, block_given?]

  table[interface] = nil

  define_method(meth) do |*args|
    table[interface]
  end

  Setter.new(table, interface)
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



5
6
7
# File 'lib/quarry/stub.rb', line 5

def object
  @object
end

Instance Method Details

#__table__Object



13
# File 'lib/quarry/stub.rb', line 13

def __table__ ; @table ; end