Module: Casting::MissingMethodClient
- Defined in:
- lib/casting/missing_method_client.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth) ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/casting/missing_method_client.rb', line 55
def method_missing(meth, ...)
attendant = method_delegate(meth)
if !!attendant
cast(meth, attendant, ...)
else
super
end
end
|
Instance Method Details
#cast_as(*attendants) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/casting/missing_method_client.rb', line 6
def cast_as(*attendants)
attendants.each do |attendant|
validate_attendant(attendant)
attendant.cast_object(self) if attendant.respond_to?(:cast_object)
__delegates__.unshift(attendant)
end
self
end
|
#delegated_methods(all = true) ⇒ Object
23
24
25
26
27
|
# File 'lib/casting/missing_method_client.rb', line 23
def delegated_methods(all=true)
__delegates__.flat_map{|attendant|
attendant_methods(attendant, all)
}
end
|
#delegated_private_methods(include_super = true) ⇒ Object
41
42
43
44
45
|
# File 'lib/casting/missing_method_client.rb', line 41
def delegated_private_methods(include_super=true)
__delegates__.flat_map{|attendant|
attendant_private_methods(attendant, include_super)
}
end
|
#delegated_protected_methods(include_super = true) ⇒ Object
35
36
37
38
39
|
# File 'lib/casting/missing_method_client.rb', line 35
def delegated_protected_methods(include_super=true)
__delegates__.flat_map{|attendant|
attendant_protected_methods(attendant, include_super)
}
end
|
#delegated_public_methods(include_super = true) ⇒ Object
29
30
31
32
33
|
# File 'lib/casting/missing_method_client.rb', line 29
def delegated_public_methods(include_super=true)
__delegates__.flat_map{|attendant|
attendant_public_methods(attendant, include_super)
}
end
|
#uncast(count = 1) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/casting/missing_method_client.rb', line 15
def uncast(count=1)
count.times do
attendant = __delegates__.shift
attendant.uncast_object(self) if attendant.respond_to?(:uncast_object)
end
self
end
|