Module: SchemaAssociations::ActiveRecord::Base::ClassMethods

Defined in:
lib/schema_associations/active_record/associations.rb

Instance Method Summary collapse

Instance Method Details

#_reflect_on_association(*args) ⇒ Object

introduced in rails 4.1



29
30
31
32
# File 'lib/schema_associations/active_record/associations.rb', line 29

def _reflect_on_association(*args)
  _load_schema_associations_associations
  super
end

#define_attribute_methods(*args) ⇒ Object



39
40
41
42
# File 'lib/schema_associations/active_record/associations.rb', line 39

def define_attribute_methods(*args)
  super
  _load_schema_associations_associations
end

#reflect_on_all_associations(*args) ⇒ Object



34
35
36
37
# File 'lib/schema_associations/active_record/associations.rb', line 34

def reflect_on_all_associations(*args)
  _load_schema_associations_associations
  super
end

#reflect_on_association(*args) ⇒ Object



23
24
25
26
# File 'lib/schema_associations/active_record/associations.rb', line 23

def reflect_on_association(*args)
  _load_schema_associations_associations
  super
end

#reflections(*args) ⇒ Object



18
19
20
21
# File 'lib/schema_associations/active_record/associations.rb', line 18

def reflections(*args)
  _load_schema_associations_associations
  super
end

#schema_associations(opts = {}) ⇒ Object

Per-model override of Config options. Use via, e.g.

class MyModel < ActiveRecord::Base
    schema_associations :auto_create => false
end

If :auto_create is not specified, it is implicitly specified as true. This allows the “non-invasive” style of using SchemaAssociations in which you set the global Config to auto_create = false, then in any model that you want auto associations you simply do:

   class MyModel < ActiveRecord::Base
       schema_associations
   end

Of course other options can be passed, such as

   class MyModel < ActiveRecord::Base
       schema_associations :concise_names => false, :except_type => :has_and_belongs_to_many
   end


65
66
67
# File 'lib/schema_associations/active_record/associations.rb', line 65

def schema_associations(opts={})
  @schema_associations_config = SchemaAssociations.config.merge({:auto_create => true}.merge(opts))
end

#schema_associations_configObject

:nodoc:



69
70
71
# File 'lib/schema_associations/active_record/associations.rb', line 69

def schema_associations_config # :nodoc:
  @schema_associations_config ||= SchemaAssociations.config.dup
end