Sha256: d39235604493a1cf70c02445626f7252751ee1678cf44f2a5007b447e3d1b41b
Contents?: true
Size: 1.84 KB
Versions: 6
Compression:
Stored size: 1.84 KB
Contents
module Leap # A basic building block of a Leap decision. # # A quorum encapsulates a specific methodology for drawing a conclusion based on a set of input information. class Quorum # The name of the quorum attr_reader :name # Quorum attribute requirements, as defined by the <tt>:needs</tt> option attr_reader :requirements # Useful attributes, as defined by the <tt>:wants</tt> option attr_reader :supplements # The quorum's methodology, as a Ruby closure. attr_reader :process # Protocols with which this quorum complies. attr_reader :compliance # (see Leap::Committee#quorum) 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 # Do the provided characteristics satisfy the quorum's requirements? # @param [Hash] characteristics # @return [TrueClass, NilClass] def satisfied_by?(characteristics) (requirements - characteristics.keys).empty? end # Does the quorum comply with the given set of protocols? # @param [Array] guideines The list of protocols we're for which we're checking compliance. # @return [TrueClass, NilClass] def complies_with?(guidelines) (guidelines - compliance).empty? end # Perform the quorum's methodology using the given characteristics. # @param [Hash] characteristics # @return The methodology's result def acknowledge(characteristics, considerations) considerations.unshift characteristics process.call(*considerations[0...process.arity]) end # All characteristics either needed or wanted by the quorum. def characteristics requirements + supplements end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
leap-0.5.5 | lib/leap/quorum.rb |
leap-0.5.4 | lib/leap/quorum.rb |
leap-0.5.3 | lib/leap/quorum.rb |
leap-0.5.2 | lib/leap/quorum.rb |
leap-0.5.1 | lib/leap/quorum.rb |
leap-0.5.0 | lib/leap/quorum.rb |