Class: TroleGroups::Macros::Configuration
- Defined in:
- lib/trole_groups/macros/configuration.rb,
lib/trole_groups/macros/configuration/base_loader.rb,
lib/trole_groups/macros/configuration/config_loader.rb,
lib/trole_groups/macros/configuration/storage_loader.rb,
lib/trole_groups/macros/configuration/strategy_loader.rb
Defined Under Namespace
Classes: BaseLoader, ConfigLoader, StorageLoader, StrategyLoader
Instance Attribute Summary collapse
-
#auto_load ⇒ Object
readonly
Returns the value of attribute auto_load.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#orm ⇒ Object
readonly
Returns the value of attribute orm.
-
#singularity ⇒ Object
readonly
Returns the value of attribute singularity.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
-
#subject_class ⇒ Object
readonly
Returns the value of attribute subject_class.
Instance Method Summary collapse
- #apply_strategy_options! ⇒ Object
- #define_hooks ⇒ Object
-
#initialize(subject_class, strategy, options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #load_adapter ⇒ Object
- #strategy_module ⇒ Object
- #trolegroups_config ⇒ Object
Constructor Details
#initialize(subject_class, strategy, options = {}) ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 |
# File 'lib/trole_groups/macros/configuration.rb', line 11 def initialize subject_class, strategy, = {} @subject_class = subject_class @strategy = strategy @orm = [:orm] || Troles::Config.default_orm @auto_load = [:auto_load] || Troles::Config.auto_load? [:strategy] = strategy @options = end |
Instance Attribute Details
#auto_load ⇒ Object (readonly)
Returns the value of attribute auto_load.
9 10 11 |
# File 'lib/trole_groups/macros/configuration.rb', line 9 def auto_load @auto_load end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/trole_groups/macros/configuration.rb', line 9 def @options end |
#orm ⇒ Object (readonly)
Returns the value of attribute orm.
9 10 11 |
# File 'lib/trole_groups/macros/configuration.rb', line 9 def orm @orm end |
#singularity ⇒ Object (readonly)
Returns the value of attribute singularity.
9 10 11 |
# File 'lib/trole_groups/macros/configuration.rb', line 9 def singularity @singularity end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
9 10 11 |
# File 'lib/trole_groups/macros/configuration.rb', line 9 def strategy @strategy end |
#subject_class ⇒ Object (readonly)
Returns the value of attribute subject_class.
9 10 11 |
# File 'lib/trole_groups/macros/configuration.rb', line 9 def subject_class @subject_class end |
Instance Method Details
#apply_strategy_options! ⇒ Object
35 36 37 38 39 40 |
# File 'lib/trole_groups/macros/configuration.rb', line 35 def trolegroups_config. # StrategyOptions.new(subject_class) # extract_macros(options).each{|m| apply_macro m} end |
#define_hooks ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/trole_groups/macros/configuration.rb', line 46 def define_hooks storage_class = storage_loader.storage_class # puts "storage_class: #{storage_class}" subject_class.send :define_method, :group_storage do @group_storage ||= storage_class end config_class = config_loader.config_class puts "config_class: #{config_class}" if Troles::Config.log_on subject_class.singleton_class.class_eval %{ def trolegroups_config @trolegroups_config ||= #{config_class}.new #{subject_class}, #{.inspect} end } end |
#load_adapter ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/trole_groups/macros/configuration.rb', line 24 def load_adapter return false if !auto_load? path = "#{namespace}/adapters/#{orm.to_s.underscore}" begin require path rescue raise "Adapter for :#{orm} could not be found at: #{path}" end end |
#strategy_module ⇒ Object
20 21 22 |
# File 'lib/trole_groups/macros/configuration.rb', line 20 def strategy_module strategy_loader.strategy_module end |
#trolegroups_config ⇒ Object
42 43 44 |
# File 'lib/trole_groups/macros/configuration.rb', line 42 def trolegroups_config subject_class.trolegroups_config end |