Sha256: 895b650c1f09e4bcebe276f3b54d8187e1e9399fe5c1195e143ef622ad55f7b1

Contents?: true

Size: 627 Bytes

Versions: 2

Compression:

Stored size: 627 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
    
    def characteristics
      requirements + supplements
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leap-0.3.3 lib/leap/quorum.rb
leap-0.3.2 lib/leap/quorum.rb