Class: SchemaAssociations::Config
- Inherits:
-
Valuable
- Object
- Valuable
- SchemaAssociations::Config
- Defined in:
- lib/schema_associations.rb
Overview
The configuation options for SchemaAssociations. Set them globally in config/initializers/schema_associations.rb
, e.g.:
SchemaAssociations.setup do |config|
config.concise_names = false
end
or override them per-model, e.g.:
class MyModel < ActiveRecord::Base
schema_associations.config :concise_names => false
end
Instance Method Summary collapse
-
#auto_create ⇒ Object
:attr_accessor: auto_create.
-
#concise_names ⇒ Object
:attr_accessor: concise_names.
-
#dup ⇒ Object
:nodoc:.
-
#except ⇒ Object
:attr_accessor: except.
-
#except_type ⇒ Object
:attr_accessor: except_type.
-
#merge(opts) ⇒ Object
:nodoc:.
-
#only ⇒ Object
:attr_accessor: only.
-
#only_type ⇒ Object
:attr_accessor: only_type.
-
#table_prefix_map ⇒ Object
:attr_accessor: table_prefix_map.
-
#update_attributes(opts) ⇒ Object
:nodoc:.
Instance Method Details
#auto_create ⇒ Object
:attr_accessor: auto_create
Whether to automatically create associations based on foreign keys. Boolean, default is true
.
30 |
# File 'lib/schema_associations.rb', line 30 has_value :auto_create, :klass => :boolean, :default => true |
#concise_names ⇒ Object
:attr_accessor: concise_names
Whether to use concise naming (strip out common prefixes from class names). Boolean, default is true
.
37 |
# File 'lib/schema_associations.rb', line 37 has_value :concise_names, :klass => :boolean, :default => true |
#dup ⇒ Object
:nodoc:
77 78 79 |
# File 'lib/schema_associations.rb', line 77 def dup #:nodoc: self.class.new(Hash[attributes.collect{ |key, val| [key, Valuable === val ? val.class.new(val.attributes) : val] }]) end |
#except ⇒ Object
:attr_accessor: except
List of association names to exclude from automatic creation. Value is a single name, an array of names, or nil
. Default is nil
.
44 |
# File 'lib/schema_associations.rb', line 44 has_value :except, :default => nil |
#except_type ⇒ Object
:attr_accessor: except_type
List of association types to exclude from automatic creation. Value is one or an array of :belongs_to
, :has_many
, :has_one
, and/or :has_and_belongs_to_many
, or nil
. Default is nil
.
59 |
# File 'lib/schema_associations.rb', line 59 has_value :except_type, :default => nil |
#merge(opts) ⇒ Object
:nodoc:
87 88 89 |
# File 'lib/schema_associations.rb', line 87 def merge(opts)#:nodoc: dup.update_attributes(opts) end |
#only ⇒ Object
:attr_accessor: only
List of association names to include in automatic creation. Value is a single name, and array of names, or nil
. Default is nil
.
51 |
# File 'lib/schema_associations.rb', line 51 has_value :only, :default => nil |
#only_type ⇒ Object
:attr_accessor: only_type
List of association types to include from automatic creation. Value is one or an array of :belongs_to
, :has_many
, :has_one
, and/or :has_and_belongs_to_many
, or nil
. Default is nil
.
67 |
# File 'lib/schema_associations.rb', line 67 has_value :only_type, :default => nil |
#table_prefix_map ⇒ Object
:attr_accessor: table_prefix_map
Hash whose keys are possible matches at the start of table names, and whose corresponding values are the prefix to use in front of class names.
75 |
# File 'lib/schema_associations.rb', line 75 has_value :table_prefix_map, :default => {} |
#update_attributes(opts) ⇒ Object
:nodoc:
81 82 83 84 85 |
# File 'lib/schema_associations.rb', line 81 def update_attributes(opts)#:nodoc: opts = opts.dup super(opts) self end |