Sha256: d8b941f3bb17496561a8f55374c712659d42772337f1b711db45185d2a258101

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

module Rulz
  module Conditions    
    module Comparison
      
      def self.load_conditions(reciever, attr)
        reciever.class_eval do
          define_rulz do
            attribute attr do
              condition "greater than" do |other|
                send(attr) > other
              end
        
              condition "less than" do |other|
                send(attr) < other
              end
        
              condition "equal to" do |other|
                send(attr) == other
              end
        
              condition "not equal to" do |other|
                opposite_of "equal to", other
              end              
            end
          end
        end
      end
      
      def self.included(base)
        base.class_eval do
          define_rulz do        
            condition "greater than" do |other|
              it > other
            end
        
            condition "less than" do |other|
              it < other
            end
        
            condition "equal to" do |other|
              it == other
            end
        
            condition "not equal to" do |other|
              opposite_of "equal to", other
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rulz-1.0.5 lib/rulz/conditions/comparison.rb
rulz-1.0.4 lib/rulz/conditions/comparison.rb
rulz-1.0.3 lib/rulz/conditions/comparison.rb
rulz-1.0.2 lib/rulz/conditions/comparison.rb
rulz-1.0.1 lib/rulz/conditions/comparison.rb
rulz-1.0.0 lib/rulz/conditions/comparison.rb