Class: Mv::Core::Services::SayConstraintsDiff
- Inherits:
-
Object
- Object
- Mv::Core::Services::SayConstraintsDiff
- Defined in:
- lib/mv/core/services/say_constraints_diff.rb
Instance Attribute Summary collapse
-
#new_constraint ⇒ Object
readonly
Returns the value of attribute new_constraint.
-
#old_constraint ⇒ Object
readonly
Returns the value of attribute old_constraint.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(old_constraint, new_constraint) ⇒ SayConstraintsDiff
constructor
A new instance of SayConstraintsDiff.
Constructor Details
#initialize(old_constraint, new_constraint) ⇒ SayConstraintsDiff
Returns a new instance of SayConstraintsDiff.
11 12 13 14 |
# File 'lib/mv/core/services/say_constraints_diff.rb', line 11 def initialize(old_constraint, new_constraint) @old_constraint = old_constraint @new_constraint = new_constraint end |
Instance Attribute Details
#new_constraint ⇒ Object (readonly)
Returns the value of attribute new_constraint.
9 10 11 |
# File 'lib/mv/core/services/say_constraints_diff.rb', line 9 def new_constraint @new_constraint end |
#old_constraint ⇒ Object (readonly)
Returns the value of attribute old_constraint.
9 10 11 |
# File 'lib/mv/core/services/say_constraints_diff.rb', line 9 def old_constraint @old_constraint end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mv/core/services/say_constraints_diff.rb', line 16 def execute ::ActiveRecord::Migration.say_with_time("#{constraint_operation} #{constraint_presenter} on table \"#{table_name}\"") do comparison[:deleted].each do |validation| say("delete #{validation_presenter(validation)}") end if comparison[:deleted] comparison[:added].each do |validation| say("create #{validation_presenter(validation)}") end if comparison[:added] yield end unless comparison.blank? end |