Class: RR::DoubleDefinitions::DoubleDefinitionCreatorProxy
- Inherits:
-
Object
- Object
- RR::DoubleDefinitions::DoubleDefinitionCreatorProxy
show all
- Defined in:
- lib/rr/double_definitions/double_definition_creator_proxy.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rr/double_definitions/double_definition_creator_proxy.rb', line 15
def initialize(creator, &block) @creator = creator
respond_to?(:class) ? self.class.blank_slate_methods : __blank_slated_class.blank_slate_methods
if block_given?
if block.arity == 1
yield(self)
else
respond_to?(:instance_eval) ? instance_eval(&block) : __blank_slated_instance_eval(&block)
end
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
28
29
30
|
# File 'lib/rr/double_definitions/double_definition_creator_proxy.rb', line 28
def method_missing(method_name, *args, &block)
@creator.create(method_name, *args, &block)
end
|
Class Method Details
.blank_slate_methods ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/rr/double_definitions/double_definition_creator_proxy.rb', line 5
def blank_slate_methods
instance_methods.each do |m|
unless m =~ /^_/ || m.to_s == 'object_id' || m.to_s == 'respond_to?' || m.to_s == 'method_missing'
alias_method "__blank_slated_#{m}", m
undef_method m
end
end
end
|
Instance Method Details
#__creator__ ⇒ Object
32
33
34
|
# File 'lib/rr/double_definitions/double_definition_creator_proxy.rb', line 32
def __creator__
@creator
end
|