class PIM::ValidationRuleBuilder
Attributes
attributes[R]
dependent_attributes[R]
disabled_block[R]
name[R]
validation_block[R]
Public Class Methods
build_validation_rule(data_module, name, *attributes, &block)
click to toggle source
# File pim.rb, line 9245 def self.build_validation_rule data_module, name, *attributes, &block # 'Old' style validation rule if not attributes.empty? rule = PIM::ValidationRule.new(name, attributes: attributes, &block) return rule end builder = ValidationRuleBuilder.new name DataModuleObject.set_data_module(builder, data_module) builder.instance_exec(&block) if block builder.build end
new(name)
click to toggle source
# File pim.rb, line 9262 def initialize name @name = name end
Public Instance Methods
build()
click to toggle source
# File pim.rb, line 9266 def build opts = { attributes: @attributes, dependent_attributes: @dependent_attributes, tags: @tags, disabled_block: @disabled_block } validation_rule = PIM::ValidationRule.new(@name, opts, &@validation_block) DataModuleObject.set_data_module(validation_rule, data_module) validation_rule end
depend_on(*attributes)
click to toggle source
# File pim.rb, line 9287 def depend_on *attributes return @dependent_attributes if attributes.empty? @dependent_attributes = attributes end
Also aliased as: depends_on
disable(&disabled_block)
click to toggle source
# File pim.rb, line 9297 def disable &disabled_block raise "Disabled block already specified" if @disabled_block @disabled_block = disabled_block @disabled_block end
validate(&validation_block)
click to toggle source
# File pim.rb, line 9303 def validate &validation_block raise "Validation block already specified" if @validation_block @validation_block = validation_block @validation_block end
validate_attribute(attribute)
click to toggle source
# File pim.rb, line 9278 def validate_attribute attribute validate_attributes attribute end
validate_attributes(*attributes)
click to toggle source
# File pim.rb, line 9282 def validate_attributes *attributes return @attributes if attributes.empty? @attributes = attributes end