Module: Fides

Extended by:
ActiveSupport::Concern
Included in:
ActiveRecord::Migration
Defined in:
lib/fides.rb,
lib/fides/version.rb,
lib/fides/sql_writer.rb,
lib/fides/sqlite3_writer.rb,
lib/fides/database_adapter.rb,
lib/fides/postgresql_writer.rb,
lib/fides/database_adapter_error.rb

Defined Under Namespace

Modules: SqlWriter Classes: DatabaseAdapterError, PostgresqlWriter, Sqlite3Writer

Constant Summary collapse

SUPPORTED_ADAPTERS =
["postgresql", "sqlite3"]
VERSION =
"1.1.0"

Instance Method Summary collapse

Instance Method Details

#add_polymorphic_triggers(opts) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fides.rb', line 17

def add_polymorphic_triggers(opts)
  raise ArgumentError, "missing :associated_models from options hash" if !opts.has_key?(:associated_models) 
  raise ArgumentError, "missing :polymorphic_model from options hash" if !opts.has_key?(:polymorphic_model)

  associated_models = opts[:associated_models]
  polymorphic_model = opts[:polymorphic_model]
  interface = opts.has_key?(:interface_name) ? opts[:interface_name] : interface_name(polymorphic_model)

  execution_statements = get_sql_generator_class.executable_add_statements(interface, associated_models, polymorphic_model)
  execution_statements.each { |statement| execute statement }
end

#remove_polymorphic_triggers(opts) ⇒ Object

Raises:

  • (ArgumentError)


29
30
31
32
33
34
35
36
37
# File 'lib/fides.rb', line 29

def remove_polymorphic_triggers(opts)
  raise ArgumentError, "missing :polymorphic_model from options hash" if !opts.has_key?(:polymorphic_model)
  
  polymorphic_model = opts[:polymorphic_model]
  interface = opts.has_key?(:interface_name) ? opts[:interface_name] : interface_name(polymorphic_model)

  execution_statements = get_sql_generator_class.executable_remove_statements(interface)
  execution_statements.each { |statement| execute statement }
end