class Wardrobe::Plugins::Validation::Validation

Constants

SPECIAL_METHODS

Public Class Methods

new(method, argument) click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 6
def initialize(method, argument)
  self[:method] = method
  self[:argument] = argument
end

Public Instance Methods

&(other) click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 39
def &(other)
  if method == :_and_
    argument << other
    self
  else
    self.class.new(:_and_, [self, other])
  end
end
>(other) click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 57
def >(other)
  self.class.new(:_then_, [self, other])
end
args() click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 19
def args
  @args ||= begin
    arr = [ method ]
    arr << argument if argument
    arr
  end
end
argument() click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 15
def argument
  self[:argument]
end
method() click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 11
def method
  self[:method]
end
type() click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 29
def type
  @type ||= begin
    if method[/^_.+_$/] || SPECIAL_METHODS.include?(method)
      :special
    else
      :value
    end
  end
end
|(other) click to toggle source
# File lib/wardrobe/plugins/validation/validation.rb, line 48
def |(other)
  if method == :_or_
    argument<< other
    self
  else
    self.class.new(:_or_, [self, other])
  end
end