Class: Wherever::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/wherever.rb

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



9
10
11
# File 'lib/wherever.rb', line 9

def initialize
  @messages = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*message) ⇒ Object



13
14
15
16
# File 'lib/wherever.rb', line 13

def method_missing(*message)
  @messages << message        # record the message
  self                        # return self so we can keep recording
end

Instance Method Details

#__replay_all_messages__(obj) ⇒ Object



18
19
20
21
22
# File 'lib/wherever.rb', line 18

def __replay_all_messages__(obj)
  @messages.inject(obj) do |obj, message|
    obj.__send__(*message)
  end
end

#to_procObject



24
25
26
# File 'lib/wherever.rb', line 24

def to_proc
  proc { |x| __replay_all_messages__(x) }
end