Class: ConventionalModels::Config::Builder
- Inherits:
-
Object
- Object
- ConventionalModels::Config::Builder
- Defined in:
- lib/conventional_models/config.rb
Instance Method Summary collapse
- #base_class(name) ⇒ Object
- #belongs_to_matcher(&block) ⇒ Object
- #belongs_to_name(&block) ⇒ Object
- #class_name(&block) ⇒ Object
- #connection(conn) ⇒ Object
- #ignore_tables(*tables) ⇒ Object
-
#initialize(config) ⇒ Builder
constructor
A new instance of Builder.
- #module_name(name) ⇒ Object
- #primary_key_name(name) ⇒ Object
Constructor Details
#initialize(config) ⇒ Builder
Returns a new instance of Builder.
12 13 14 15 16 17 18 19 20 |
# File 'lib/conventional_models/config.rb', line 12 def initialize(config) @config = config belongs_to_matcher {|column| column.name.end_with? "_id"} belongs_to_name {|column| column.name.gsub(/_id$/, "")} primary_key_name "id" class_name {|table_name| table_name.singularize.camelize} ignore_tables "schema_migrations", "sqlite_sequence", "sysdiagrams" base_class "::ActiveRecord::Base" end |
Instance Method Details
#base_class(name) ⇒ Object
50 51 52 |
# File 'lib/conventional_models/config.rb', line 50 def base_class(name) @config.base_class = name end |
#belongs_to_matcher(&block) ⇒ Object
30 31 32 |
# File 'lib/conventional_models/config.rb', line 30 def belongs_to_matcher(&block) @config.belongs_to_matcher = block end |
#belongs_to_name(&block) ⇒ Object
34 35 36 |
# File 'lib/conventional_models/config.rb', line 34 def belongs_to_name(&block) @config.belongs_to_name = block end |
#class_name(&block) ⇒ Object
38 39 40 |
# File 'lib/conventional_models/config.rb', line 38 def class_name(&block) @config.class_name = block end |
#connection(conn) ⇒ Object
42 43 44 |
# File 'lib/conventional_models/config.rb', line 42 def connection(conn) @config.connection = conn end |
#ignore_tables(*tables) ⇒ Object
22 23 24 |
# File 'lib/conventional_models/config.rb', line 22 def ignore_tables(*tables) @config.ignored_tables = tables.map{|t|t.to_s} end |
#module_name(name) ⇒ Object
46 47 48 |
# File 'lib/conventional_models/config.rb', line 46 def module_name(name) @config.module_name = name end |
#primary_key_name(name) ⇒ Object
26 27 28 |
# File 'lib/conventional_models/config.rb', line 26 def primary_key_name(name) @config.primary_key_name = name end |