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



31
32
33
34
# File 'lib/schema_associations/active_record/associations.rb', line 31

def _reflect_on_association(*args)
  _load_schema_associations_associations
  super
end

#define_attribute_methods(*args) ⇒ Object



41
42
43
44
# File 'lib/schema_associations/active_record/associations.rb', line 41

def define_attribute_methods(*args)
  super
  _load_schema_associations_associations
end

#reflect_on_all_associations(*args) ⇒ Object



36
37
38
39
# File 'lib/schema_associations/active_record/associations.rb', line 36

def reflect_on_all_associations(*args)
  _load_schema_associations_associations
  super
end

#reflect_on_association(*args) ⇒ Object



25
26
27
28
# File 'lib/schema_associations/active_record/associations.rb', line 25

def reflect_on_association(*args)
  _load_schema_associations_associations
  super
end

#reflections(*args) ⇒ Object



20
21
22
23
# File 'lib/schema_associations/active_record/associations.rb', line 20

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


67
68
69
# File 'lib/schema_associations/active_record/associations.rb', line 67

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

#schema_associations_configObject

:nodoc:



71
72
73
# File 'lib/schema_associations/active_record/associations.rb', line 71

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