class Mv::Core::Services::CompareConstraints

Attributes

new_constraint[R]
old_constraint[R]

Public Class Methods

new(old_constraint, new_constraint) click to toggle source
# 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

Public Instance Methods

execute() click to toggle source
# 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

Private Instance Methods

new_validations() click to toggle source
# File lib/mv/core/services/compare_constraints.rb, line 25
def new_validations
  @new_validations ||= new_constraint.try(:validations) || []
end
old_validations() click to toggle source
# File lib/mv/core/services/compare_constraints.rb, line 21
def old_validations
  @old_validations ||= old_constraint.try(:validations) || []
end