Module: Casting::Client

Defined in:
lib/casting/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object


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

def self.extended(base)
  unless base.respond_to?('delegate')
    add_delegate_method_to(base.singleton_class)
  end
end

.included(base) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/casting/client.rb', line 8

def self.included(base)
  def base.delegate_missing_methods(*which)
    Casting::Client.set_delegation_strategy(self, *which.reverse)
  end

  unless base.method_defined?('delegate')
    add_delegate_method_to(base)
  end
end

Instance Method Details

#cast(delegated_method_name, attendant, *args, &block) ⇒ Object


28
29
30
31
# File 'lib/casting/client.rb', line 28

def cast(delegated_method_name, attendant, *args, &block)
  validate_attendant(attendant)
  delegation(delegated_method_name).to(attendant).with(*args, &block).call
end

#delegate_missing_methods(*which) ⇒ Object


33
34
35
# File 'lib/casting/client.rb', line 33

def delegate_missing_methods(*which)
  Casting::Client.set_delegation_strategy(self.singleton_class, *which.reverse)
end

#delegation(delegated_method_name) ⇒ Object


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

def delegation(delegated_method_name)
  Casting::Delegation.new(delegated_method_name, self)
end