Class: Troles::Macros::Configuration::BaseLoader
- Inherits:
-
Object
- Object
- Troles::Macros::Configuration::BaseLoader
show all
- Defined in:
- lib/troles/common/macros/configuration/base_loader.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(strategy, orm) ⇒ BaseLoader
Returns a new instance of BaseLoader.
6
7
8
9
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 6
def initialize strategy, orm
@strategy = strategy
@orm = orm || Troles::Config.default_orm
end
|
Instance Attribute Details
Returns the value of attribute orm.
4
5
6
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 4
def orm
@orm
end
|
Returns the value of attribute strategy.
4
5
6
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 4
def strategy
@strategy
end
|
Instance Method Details
#base_class ⇒ Object
25
26
27
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 25
def base_class
"Base#{singularity.to_s.camelize}"
end
|
#namespace ⇒ Object
29
30
31
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 29
def namespace
singularity == :many ? 'Troles' : 'Trole'
end
|
#orm_namespace ⇒ Object
33
34
35
36
37
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 33
def orm_namespace
ns = namespace
ns << "::#{orm.to_s.camelize}" if orm
ns
end
|
#singularity ⇒ Object
11
12
13
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 11
def singularity
(strategy =~ /_many$/) ? :many : :one
end
|
#try_module(full_name) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 15
def try_module full_name
begin
full_name.constantize
true
rescue
false
end
end
|