Module: Konstructor
- Defined in:
- lib/konstructor.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, KonstructorMethodHook, SimpleMethodHook
Classes: Factory, IncludeInModuleError, ReservedNameError
Constant Summary
collapse
- DEFAULT_NAMES =
[:initialize]
- RESERVED_NAMES =
[:new, :initialize]
- VERSION =
'0.1.0'
Class Method Summary
collapse
Class Method Details
.declare(klass, new_names) ⇒ Object
38
39
40
41
|
# File 'lib/konstructor.rb', line 38
def declare(klass, new_names)
setup_method_added_hook(klass)
get_or_init_factory(klass).declare(new_names)
end
|
.declared?(klass, name) ⇒ Boolean
29
30
31
32
33
34
35
36
|
# File 'lib/konstructor.rb', line 29
def declared?(klass, name)
konstructor = get_factory(klass)
if konstructor
konstructor.declared?(name.to_sym)
else
false
end
end
|
.default?(name) ⇒ Boolean
25
26
27
|
# File 'lib/konstructor.rb', line 25
def default?(name)
DEFAULT_NAMES.include?(name.to_sym)
end
|
.is?(klass, name) ⇒ Boolean
47
48
49
|
# File 'lib/konstructor.rb', line 47
def is?(klass, name)
default?(name) || declared?(klass, name)
end
|
.method_added_to_klass(klass, name) ⇒ Object
43
44
45
|
# File 'lib/konstructor.rb', line 43
def method_added_to_klass(klass, name)
get_or_init_factory(klass).method_added_to_klass(name)
end
|
.reserved?(name) ⇒ Boolean
21
22
23
|
# File 'lib/konstructor.rb', line 21
def reserved?(name)
RESERVED_NAMES.include?(name.to_sym)
end
|