Module: SchemaMonkey::CoreExtensions::ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/schema_monkey/core_extensions/active_record/connection_adapters/table_definition.rb
Class Method Summary collapse
Instance Method Summary collapse
- #belongs_to_with_schema_monkey(name, options = {}) ⇒ Object
- #column_with_schema_monkey(name, type, options = {}) ⇒ Object
- #index_with_schema_monkey(*args) ⇒ Object
- #references_with_schema_monkey(name, options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/schema_monkey/core_extensions/active_record/connection_adapters/table_definition.rb', line 5 def self.included(base) base.class_eval do alias_method_chain :column, :schema_monkey alias_method_chain :references, :schema_monkey alias_method_chain :belongs_to, :schema_monkey alias_method_chain :index, :schema_monkey end end |
Instance Method Details
#belongs_to_with_schema_monkey(name, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/schema_monkey/core_extensions/active_record/connection_adapters/table_definition.rb', line 26 def belongs_to_with_schema_monkey(name, = {}) SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: "#{name}_id", type: :reference, options: .deep_dup) do |env| belongs_to_without_schema_monkey env.column_name.sub(/_id$/, ''), env. end end |
#column_with_schema_monkey(name, type, options = {}) ⇒ Object
14 15 16 17 18 |
# File 'lib/schema_monkey/core_extensions/active_record/connection_adapters/table_definition.rb', line 14 def column_with_schema_monkey(name, type, = {}) SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: name, type: type, options: .deep_dup) do |env| column_without_schema_monkey env.column_name, env.type, env. end end |
#index_with_schema_monkey(*args) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/schema_monkey/core_extensions/active_record/connection_adapters/table_definition.rb', line 32 def index_with_schema_monkey(*args) = args. column_name = args.first SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :define, table_name: self.name, column_names: column_name, options: .deep_dup) do |env| index_without_schema_monkey env.column_names, env. end end |
#references_with_schema_monkey(name, options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/schema_monkey/core_extensions/active_record/connection_adapters/table_definition.rb', line 20 def references_with_schema_monkey(name, = {}) SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: "#{name}_id", type: :reference, options: .deep_dup) do |env| references_without_schema_monkey env.column_name.sub(/_id$/, ''), env. end end |