Class: Trole::Mongoid::Config

Inherits:
Troles::Common::Config show all
Defined in:
lib/trole/adapters/mongoid/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, #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
# File 'lib/trole/adapters/mongoid/config.rb', line 4

def initialize subject_class, options = {}
  super
end

Instance Method Details

#configure_fieldObject



18
19
20
21
22
23
24
25
26
# File 'lib/trole/adapters/mongoid/config.rb', line 18

def configure_field
  type = case strategy
  when :bit_one
    Boolean
  when :string_one
    String
  end
  subject_class.send(:field, role_field, type) if type      
end

#configure_relationObject



8
9
10
11
12
13
14
15
16
# File 'lib/trole/adapters/mongoid/config.rb', line 8

def configure_relation
  case strategy
  when :ref_one
    has_one_for subject_class, object_model
    belongs_to_for object_model, subject_class
  when :embed_one
    embeds_one subject_class, object_model
  end
end