Module: PolymorphicConstraints::ConnectionAdapters::PostgreSQLAdapter
Instance Method Summary
collapse
#get_polymorphic_models
#strip_non_essential_spaces
Instance Method Details
#add_polymorphic_constraints(relation, associated_table, options = {}) ⇒ Object
Also known as:
update_polymorphic_constraints
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/polymorphic_constraints/connection_adapters/postgresql_adapter.rb', line 15
def add_polymorphic_constraints(relation, associated_table, options = {})
polymorphic_models = options.fetch(:polymorphic_models) { get_polymorphic_models(relation) }
statements = []
statements << drop_constraints(relation)
statements << generate_upsert_constraints(relation, associated_table, polymorphic_models)
statements << generate_delete_constraints(relation, associated_table, polymorphic_models)
statements.each { |statement| execute statement }
end
|
#remove_polymorphic_constraints(relation) ⇒ Object
26
27
28
29
|
# File 'lib/polymorphic_constraints/connection_adapters/postgresql_adapter.rb', line 26
def remove_polymorphic_constraints(relation)
statement = drop_constraints(relation)
execute statement
end
|
#supports_polymorphic_constraints? ⇒ Boolean
11
12
13
|
# File 'lib/polymorphic_constraints/connection_adapters/postgresql_adapter.rb', line 11
def supports_polymorphic_constraints?
true
end
|