Sha256: 7842321c6e9f405a10e2a67ef33f1ee25fd4adf8203bbb010fb2fcfa23b6f853

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

Stored size: 603 Bytes

Contents

module Leap
  module Subject
    def self.extended(base)
      base.instance_variable_set :@decisions, {}
      base.send :attr_reader, :deliberations
    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|
        @deliberations ||= {}
        @deliberations[goal] = self.class.decisions[goal].make send(self.class.decisions[goal].signature_method), *considerations
        @deliberations[goal][goal]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
leap-0.3.3 lib/leap/subject.rb
leap-0.3.2 lib/leap/subject.rb
leap-0.3.1 lib/leap/subject.rb
leap-0.3.0 lib/leap/subject.rb