Class: Peck::Delegates

Inherits:
Set show all
Defined in:
lib/peck/delegates.rb

Constant Summary collapse

MESSAGES =
%w(
  started
  finished
  started_specification
  finished_specification
  received_missing
  received_exception
).freeze

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/peck/delegates.rb', line 24

def method_missing(method, *args, &block)
  method = method.to_s
  if supported_messages.include?(method)
    each do |delegate|
      if delegate.respond_to?(method)
        delegate.send(method, *args, &block)
      end
    end
  else
    super
  end
end

Class Method Details

.instanceObject



7
8
9
# File 'lib/peck/delegates.rb', line 7

def self.instance
  @instance ||= new
end

Instance Method Details

#supported_messagesObject



20
21
22
# File 'lib/peck/delegates.rb', line 20

def supported_messages
  MESSAGES
end