Sha256: 2189e0310b25d1dfdf5eb9f2fb9ec206000490a5c7cfff11fdacc6654313dd05

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 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(send(self.class.decisions[goal].signature_method), *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.4 lib/leap/subject.rb
leap-0.4.3 lib/leap/subject.rb