Class: Mv::Core::Constraint::Builder::Index
- Inherits:
-
Base
- Object
- Base
- Mv::Core::Constraint::Builder::Index
show all
- Defined in:
- lib/mv/core/constraint/builder/index.rb
Instance Attribute Summary
Attributes inherited from Base
#constraint
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #validation_builders, validation_builders_factory
Instance Method Details
#create ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/mv/core/constraint/builder/index.rb', line 8
def create
super
constraint.validations.group_by(&:table_name).each do |table_name, validations|
remove_index(table_name)
add_index(table_name, validations.collect(&:column_name))
end
end
|
#delete ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/mv/core/constraint/builder/index.rb', line 17
def delete
super
constraint.validations.group_by(&:table_name).each do |table_name, validations|
remove_index(table_name)
end
end
|
#update(new_constraint_builder) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/mv/core/constraint/builder/index.rb', line 25
def update new_constraint_builder
super
delete
new_constraint_builder.create
end
|