Class: ActiveSchema::SchemaFeeder
Instance Attribute Summary
Attributes inherited from Feeder
#associations_generator, #table_hub, #validations_generator
Instance Method Summary
collapse
#model_loaded
Methods inherited from Feeder
#add_model, #dispatch_attachments, #generate_assocations, #generate_associations_between, #generate_directed_associations_between, #generate_validations, #initialize
Instance Method Details
#add_foreign_key(from_table, to_table, options = {}) ⇒ Object
27
28
29
30
|
# File 'lib/active_schema/schema_feeder.rb', line 27
def add_foreign_key(from_table, to_table, options = {})
column = options[:column] ? options[:column] : "#{to_table.singularize}_id"
table_hub.add_foreign_key(from_table, to_table, column)
end
|
#add_index(table_name, column_name, options = {}) ⇒ Object
21
22
23
24
25
|
# File 'lib/active_schema/schema_feeder.rb', line 21
def add_index(table_name, column_name, options = {})
index = ::ActiveRecord::ConnectionAdapters::IndexDefinition\
.new(table_name, options[:name], options[:unique], Array(column_name), options[:lengths])
table_hub.add_index(table_name, index)
end
|
#feed {|_self| ... } ⇒ Object
36
37
38
|
# File 'lib/active_schema/schema_feeder.rb', line 36
def feed
yield self
end
|