Sha256: 7882c8bc2e4987d120cc585fafb298406cbab198cc34bbaf00d3489490b641cf

Contents?: true

Size: 557 Bytes

Versions: 7

Compression:

Stored size: 557 Bytes

Contents

module Leap
  class Quorum
    attr_reader :name, :requirements, :supplements, :process
    def initialize(name, options, blk)
      @name = name
      @requirements = Array.wrap options[:needs]
      @supplements = Array.wrap options[:appreciates]
      @process = blk
    end
    
    def satisfied_by?(characteristics)
      (requirements - characteristics.keys).empty?
    end
    
    def acknowledge(characteristics, considerations)
      considerations.unshift characteristics
      process.call(*considerations[0...process.arity])
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
leap-0.3.1 lib/leap/quorum.rb
leap-0.3.0 lib/leap/quorum.rb
leap-0.2.6 lib/leap/quorum.rb
leap-0.2.5 lib/leap/quorum.rb
leap-0.2.4 lib/leap/quorum.rb
leap-0.2.3 lib/leap/quorum.rb
leap-0.2.2 lib/leap/quorum.rb