Sha256: baf624bd6422edd4208e4a30eb557411c67ebfc280b0f1b6560eb458cad1563d

Contents?: true

Size: 777 Bytes

Versions: 4

Compression:

Stored size: 777 Bytes

Contents

module Leap
  class Quorum
    attr_reader :name, :requirements, :supplements, :process, :compliance
    def initialize(name, options, blk)
      @name = name
      @requirements = Array.wrap options[:needs]
      @supplements = Array.wrap options[:appreciates]
      @compliance = Array.wrap options[:complies]
      @process = blk
    end
    
    def satisfied_by?(characteristics)
      (requirements - characteristics.keys).empty?
    end
    
    def complies_with?(guidelines)
      (guidelines - compliance).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

4 entries across 4 versions & 1 rubygems

Version Path
leap-0.4.3 lib/leap/quorum.rb
leap-0.4.2 lib/leap/quorum.rb
leap-0.4.1 lib/leap/quorum.rb
leap-0.4.0 lib/leap/quorum.rb