Module: Konstructor
- Extended by:
- MonitorMixin
- Defined in:
- lib/konstructor/main.rb,
lib/konstructor/factory.rb,
lib/konstructor/version.rb,
lib/konstructor/exceptions.rb,
lib/konstructor/simple_method_hook.rb,
lib/konstructor/konstructor_method_hook.rb
Defined Under Namespace
Modules: KonstructorMethod
Classes: DeclaringInheritedError, Error, IncludingInModuleError, ReservedNameError
Constant Summary
collapse
- DEFAULT_NAMES =
[:initialize]
- RESERVED_NAMES =
[:new, :initialize]
- VERSION =
'1.0.2'
Class Method Summary
collapse
Class Method Details
.declare(klass, new_method_names) ⇒ Object
93
94
95
96
97
98
|
# File 'lib/konstructor/main.rb', line 93
def declare(klass, new_method_names)
setup_method_added_hook(klass)
synchronize do
get_or_init_factory(klass).declare(new_method_names)
end
end
|
.declared?(klass, method_name) ⇒ Boolean
Once method is a konstructor, it is always a konstructor, this differs from the way private, protected works. If overriding method isn’t repeatedly marked as private it becomes public.
84
85
86
87
88
89
90
91
|
# File 'lib/konstructor/main.rb', line 84
def declared?(klass, method_name)
konstructor = get_factory(klass)
if konstructor
konstructor.declared?(method_name.to_sym)
else
false
end
end
|
.default?(name) ⇒ Boolean
77
78
79
|
# File 'lib/konstructor/main.rb', line 77
def default?(name)
DEFAULT_NAMES.include?(name.to_sym)
end
|
.is?(klass, method_name) ⇒ Boolean
106
107
108
|
# File 'lib/konstructor/main.rb', line 106
def is?(klass, method_name)
default?(method_name) || declared?(klass, method_name)
end
|
.method_added_to_klass(klass, method_name) ⇒ Object
100
101
102
103
104
|
# File 'lib/konstructor/main.rb', line 100
def method_added_to_klass(klass, method_name)
synchronize do
get_or_init_factory(klass).method_added_to_klass(method_name)
end
end
|
.reserved?(name) ⇒ Boolean
73
74
75
|
# File 'lib/konstructor/main.rb', line 73
def reserved?(name)
RESERVED_NAMES.include?(name.to_sym)
end
|