Class: Trole::Adapters::ActiveRecord::Config

Inherits:
Troles::Common::Config show all
Defined in:
lib/trole/adapters/active_record/config.rb

Instance Attribute Summary

Attributes inherited from Troles::Common::Config

#generic, #log_on, #orm, #strategy, #subject_class

Attributes included from Troles::Common::Config::ClassMethods

#auto_load, #default_orm, #log_on

Instance Method Summary collapse

Methods inherited from Troles::Common::Config

#apply_options!, #auto_config, #auto_config?, #configure!, #default_main_field, #generic?, #log_on?, #main_field=, #singularity, sub_modules

Methods included from Troles::Common::Config::ClassMethods

#auto_config, #auto_config?, #auto_load?, #log_on?

Constructor Details

#initialize(subject_class, options = {}) ⇒ Config

Returns a new instance of Config.



4
5
6
7
8
# File 'lib/trole/adapters/active_record/config.rb', line 4

def initialize subject_class, options = {}
  super
  puts "models classes: #{subject_class}, #{object_model}"
  @models = ::Schemaker::Models.new(subject_class, object_model, nil)
end

Instance Method Details

#configure_fieldObject

AR sets this up on its own using DB Table info



34
35
# File 'lib/trole/adapters/active_record/config.rb', line 34

def configure_field
end

#configure_relationObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/trole/adapters/active_record/config.rb', line 10

def configure_relation
  case strategy
  when :ref_one        
    obj_model.create_belongs_to subject_class, :key => main_field 
    subj_model.create_has_one object_model
  when :embed_one
    raise "EmbedOne is currently not supported by the Active Record adapter. It will be soon..."
    #clazz.send(:embeds_one, role_model_key, :class_name => role_model_class_name)      
  end
end

#main_fieldObject



29
30
31
# File 'lib/trole/adapters/active_record/config.rb', line 29

def main_field
  role_field
end

#obj_modelObject



21
22
23
# File 'lib/trole/adapters/active_record/config.rb', line 21

def obj_model
  models.object_model
end

#subj_modelObject



25
26
27
# File 'lib/trole/adapters/active_record/config.rb', line 25

def subj_model
  models.subject_model
end