class BazaModels::Validators::BaseValidator

Attributes

args[R]
attribute_name[R]

Public Class Methods

new(attribute_name, args) click to toggle source
# File lib/baza_models/validators/base_validator.rb, line 4
def initialize(attribute_name, args)
  @attribute_name = attribute_name
  @args = args
end

Public Instance Methods

fire?(model) click to toggle source
# File lib/baza_models/validators/base_validator.rb, line 9
def fire?(model)
  result = true

  if @args[:if]
    if @args.fetch(:if).is_a?(Symbol)
      result = model.__send__(@args.fetch(:if))
    else
      raise "Unknown 'if'-argument: #{@args[:if]} (#{@args[:if].class.name})"
    end
  end

  result
end