Sha256: f3e5369c69988ebddc3accce7378e1afc719d06341d0e5f557aac62dd5d0f1ac

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

Contents

module Leap
  class Committee
    include XmlSerializer

    attr_reader :name, :quorums
    
    def initialize(name)
      @name = name
      @quorums = []
    end
    
    def report(subject, characteristics, considerations, options = {})
      quorums.grab do |quorum|
        next unless quorum.satisfied_by? characteristics and quorum.complies_with? Array.wrap(options[:comply])
        if conclusion = quorum.acknowledge(characteristics.slice(*quorum.characteristics), considerations.dup)
          ::Leap::Report.new subject, self, quorum => conclusion
        end
      end
    end

    def as_json(*)
      {
        'name' => name.to_s,
        'quorums' => quorums.map(&:as_json)
      }
    end

    def to_xml(options = {})
      super options do |xml|
        xml.committee do |committee_block|
          committee_block.name name.to_s, :type => 'string'
          array_to_xml(committee_block, :quorums, quorums)
        end
      end
    end
    
    include ::Blockenspiel::DSL
    def quorum(name, options = {}, &blk)
      @quorums << ::Leap::Quorum.new(name, options, blk)
    end
    
    def default(options = {}, &blk)
      quorum 'default', options, &blk
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
leap-0.4.6 lib/leap/committee.rb
leap-0.4.5 lib/leap/committee.rb