Sha256: f1f2eae3fbc263ca639f535136e42cf37804a4eb0f84e6ab16371ef15cbd352a

Contents?: true

Size: 688 Bytes

Versions: 2

Compression:

Stored size: 688 Bytes

Contents

module Micronaut

  class World
  
    def self.reset
      @behaviour_groups = []
    end

    reset
  
    def self.behaviour_groups
      @behaviour_groups
    end
    
    def self.find(conditions={})
      return [] if conditions.empty?
      
      behaviour_groups.select do |group|
        conditions.all? do |key, value|
          case value
          when Hash
            value.all? { |k, v| group.metadata[key][k] == v }
          when Regexp
            group.metadata[key] =~ value
          when Proc
            value.call(group.metadata[key]) rescue false
          else
            group.metadata[key] == value
          end
        end
      end
    end
  
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spicycode-micronaut-0.0.5 lib/micronaut/world.rb
spicycode-micronaut-0.0.6 lib/micronaut/world.rb