Module: IronTrail::Migration
- Defined in:
- lib/iron_trail/migration.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/iron_trail/migration.rb', line 5 def method_missing(method, *args) running_from_schema = is_a?(ActiveRecord::Schema) || (defined?(ActiveRecord::Schema::Definition) && is_a?(ActiveRecord::Schema::Definition)) result = super return result unless IronTrail.enabled? && method == :create_table start_at_version = IronTrail.config.track_migrations_starting_at_version if !running_from_schema && start_at_version return result if self.version < Integer(start_at_version) end table_name = args.first.to_s return result if IronTrail.ignore_table?(table_name) if running_from_schema @irontrail_missing_track ||= [] @irontrail_missing_track << table_name return result end db_fun = IronTrail::DbFunctions.new(connection) if db_fun.function_present? db_fun.enable_tracking_for_table(table_name) else Rails.logger.warn("IronTrail will not create trigger for table #{table_name} because the trigger function does not exist in the database.") end result end |