Sha256: 150563aaeddbb0111980b36b3c04aa5c588a73ebb2463516a66bbf587a67320e

Contents?: true

Size: 509 Bytes

Versions: 6

Compression:

Stored size: 509 Bytes

Contents

module Rulz
  class Condition
    attr_accessor :name, :proc
    
    def initialize(name, klass, proc)
      @name = name
      @proc = proc
      klass.instance_exec self do |condition|
        @rulz_conditions ||= []
        @rulz_conditions << condition 
      end
    end
    
    def self.find(klass, name)
      result = klass.instance_eval { @rulz_conditions }.find {|c| c.name == name }
      raise ArgumentError, "Condition '#{name}' does not exist" unless result
      result
    end
    
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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