Class: Troles::Common::Macros::Configuration::BaseLoader
- Inherits:
-
Object
- Object
- Troles::Common::Macros::Configuration::BaseLoader
show all
- Includes:
- ClassExt
- 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.
8
9
10
11
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 8
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
21
22
23
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 21
def base_class
"Base#{singularity.to_s.camelize}"
end
|
#namespace ⇒ Object
25
26
27
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 25
def namespace
singularity == :many ? 'Troles' : 'Trole'
end
|
#orm_namespace ⇒ Object
29
30
31
32
33
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 29
def orm_namespace
ns = namespace
ns << "::#{orm.to_s.camelize}" if orm
ns
end
|
#singularity ⇒ Object
13
14
15
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 13
def singularity
(strategy =~ /_many$/) ? :many : :one
end
|
#strategy_class ⇒ Object
17
18
19
|
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 17
def strategy_class
strategy.to_s.camelize
end
|