Sha256: dd9454ca4c1254a3859e8d96a47257a6ae393c7f096e436c91d4fd95afd4a34a

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

module Leap
  module Subject
    def self.extended(base)
      base.instance_variable_set :@decisions, {}
      base.send :attr_reader, :deliberations
      base.send :include, ::Leap::ImplicitAttributes
    end
    attr_reader :decisions
    def decide(goal, options = {}, &blk)
      decisions[goal] = ::Leap::Decision.new goal, options
      Blockenspiel.invoke(blk, decisions[goal])
      define_method goal do |*considerations|
        options = considerations.extract_options!
        @deliberations ||= {}
        @deliberations[goal] = self.class.decisions[goal].make(self, *considerations.push(options))
        @deliberations[goal][goal] or raise ::Leap::NoSolutionError
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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