module Rulz::Conditions::String
Public Class Methods
included(base)
click to toggle source
# File lib/rulz/conditions/string.rb, line 32 def self.included(base) base.class_eval do include Rulz::Conditions::Container define_rulz do condition "equals" do |other| send(attr) == other end condition "does not equal" do |other| opposite_of "equal to", other end condition "does not match" do |regex| it.scan(regex).empty? end condition "matches" do |regex| opposite_of "does not match", regex end condition "like" do |other| it.downcase == other.downcase end condition "not like" do |other| opposite_of "like", other end end end end
load_conditions(reciever, attr)
click to toggle source
# File lib/rulz/conditions/string.rb, line 5 def self.load_conditions(reciever, attr) reciever.class_eval do define_rulz do attribute attr do condition "does not match" do |regex| send(attr).scan(regex).empty? end condition "matches" do |regex| opposite_of "does not match", regex end condition "like" do |other| send(attr).downcase == other.downcase end condition "not like" do |other| opposite_of "like", other end condition "equals" do |other| send(attr) == other end condition "does not equal" do |other| opposite_of "equal to", other end end end end end