Class: Mv::Core::Services::CompareConstraints

Inherits:
Object
  • Object
show all
Defined in:
lib/mv/core/services/compare_constraints.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(old_constraint, new_constraint) ⇒ CompareConstraints

Returns a new instance of CompareConstraints.



7
8
9
10
# File 'lib/mv/core/services/compare_constraints.rb', line 7

def initialize(old_constraint, new_constraint)
  @old_constraint = old_constraint
  @new_constraint = new_constraint
end

Instance Attribute Details

#new_constraintObject (readonly)

Returns the value of attribute new_constraint.



5
6
7
# File 'lib/mv/core/services/compare_constraints.rb', line 5

def new_constraint
  @new_constraint
end

#old_constraintObject (readonly)

Returns the value of attribute old_constraint.



5
6
7
# File 'lib/mv/core/services/compare_constraints.rb', line 5

def old_constraint
  @old_constraint
end

Instance Method Details

#executeObject



12
13
14
15
16
17
# File 'lib/mv/core/services/compare_constraints.rb', line 12

def execute
  {
    deleted: old_validations - new_validations, 
    added: new_validations - old_validations
  }.delete_if{ |key, value| value.blank? }
end