class PIM::ValidationRule

Attributes

attributes[RW]
dependent_attributes[RW]
disabled_block[RW]
name[RW]
tags[RW]
validation_block[RW]

Public Class Methods

new(name, opts = {}) click to toggle source
# File pim.rb, line 8878
def initialize name, opts = {}, &validation_block
  @name = name
  @attributes = (PIM.symbolized_array(PIM.get_value(opts, :attributes)) || Set.new).to_set
  @dependent_attributes = (PIM.symbolized_array(PIM.get_value(opts, :dependent_attributes)) || Set.new).to_set
  @tags = PIM.stringified_array(PIM.get_value(opts, :tags))
  @tags = @tags.to_set unless @tags.nil?
  @disabled_block = PIM.get_value(opts, :disabled_block)
  @validation_block = validation_block
end

Public Instance Methods

depend_on() click to toggle source
# File pim.rb, line 8901
def depend_on
  dependent_attributes
end
Also aliased as: depends_on
depends_on()
Alias for: depend_on
disabled?(context) click to toggle source
# File pim.rb, line 8888
def disabled? context
  return @disabled_block.call(context) if @disabled_block
  return false
end
execute(context) click to toggle source
# File pim.rb, line 8893
def execute context
  @validation_block.call(context)
end
validate_attributes() click to toggle source
# File pim.rb, line 8897
def validate_attributes
  attributes
end