Module: Casting::Client

Defined in:
lib/casting/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



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

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

.included(base) ⇒ Object



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

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) ⇒ Object



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

def cast(delegated_method_name, attendant, ...)
  validate_attendant(attendant)
  delegation(delegated_method_name).to(attendant).call(...)
end

#delegate_missing_methods(*which) ⇒ Object



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

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

#delegation(delegated_method_name) ⇒ Object



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

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