Class: Troles::Common::Macros::Configuration::BaseLoader

Inherits:
Object
  • Object
show all
Includes:
ClassExt
Defined in:
lib/troles/common/macros/configuration/base_loader.rb

Direct Known Subclasses

ConfigLoader, StorageLoader, StrategyLoader

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

#ormObject (readonly)

Returns the value of attribute orm.



4
5
6
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 4

def orm
  @orm
end

#strategyObject (readonly)

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_classObject



21
22
23
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 21

def base_class
  "Base#{singularity.to_s.camelize}"
end

#namespaceObject



25
26
27
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 25

def namespace
  singularity == :many ? 'Troles' : 'Trole'      
end

#orm_namespaceObject



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

#singularityObject



13
14
15
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 13

def singularity
  (strategy =~ /_many$/) ? :many : :one
end

#strategy_classObject



17
18
19
# File 'lib/troles/common/macros/configuration/base_loader.rb', line 17

def strategy_class
  strategy.to_s.camelize
end