module Rulz::Conditions::Container

Public Class Methods

included(base) click to toggle source
# File lib/rulz/conditions/container.rb, line 21
def self.included(base)
  base.class_eval do
    define_rulz do
      condition "contains" do |other|
        it.include? other
      end
      condition "does not contain" do |other|
        opposite_of "contains", other
      end
    end
  end
end
load_conditions(reciever, attr) click to toggle source
# File lib/rulz/conditions/container.rb, line 5
def self.load_conditions(reciever, attr)
  reciever.class_eval do
    define_rulz do
      attribute attr do
        condition "contains" do |other|
          send(attr).include? other
        end
        condition "does not contain" do |other|
          opposite_of "contains", other
        end
      end
    end
  end
end