daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Jun 22nd, 2018 61 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. require 'tiny_prolog_ext.rb'
  2. require File.expand_path(File.dirname(__FILE__) + '/tiny_prolog_ext.rb')
  3. require 'tiny_prolog.rb'
  4.  
  5. class BusinessLogic
  6.  
  7.   def initialize
  8.  
  9.  
  10.  
  11.     @action = pred 'action'
  12.     @wait_payment = pred 'wait_payment'
  13.     @send_deliver = pred 'send_deliver'
  14.     @send_ack = pred 'send_ack'
  15.     @canceling_order = pred 'canceling_order'
  16.     @cancel = pred 'cancel'
  17.     @complete = pred 'complete'
  18.  
  19.     @payment_recieved = pred 'payment_recieved'
  20.     @timeout_occur = pred 'timeout_occur'
  21.     @cancel_recieved = pred 'cancel_recieved'
  22.     @cancel_order = pred 'cancel_order'
  23.     @deliver_cancel = pred 'deliver_cancel'
  24.     @deliver_completed = pred 'deliver_completed'
  25.     @ack_sended = pred 'ack_sended'
  26.  
  27.  
  28.     ['action', 'wait_payment', 'send_deliver', 'send_ack', 'canceling_order', 'cancel', 'complete'].each { |meth| self.send(meth)}
  29.     ['payment_recieved', 'timeout_occur', 'cancel_recieved', 'cancel_order', 'deliver_cancel', 'deliver_completed', 'ack_sended'].each { |meth| self.send(meth)}
  30.  
  31.        
  32.     action['wait_payment'] <<= [n0t(payment_recieved[]), n0t(cancel_recieved[]), n0t(timeout_occur[])]
  33.     action['send_deliver'] <<= [payment_recieved[], action['wait_payment'], n0t(cancel_recieved[]), n0t(timeout_occur[])]
  34.     action['complete'] <<= [deliver_completed[], action['send_deliver']]
  35.  
  36.     action['cancel'] <<= [timeout_occur[]]
  37.     action['cancel'] <<= [cancel_recieved[]]
  38.     action['cancel'] <<= [action['send_deliver'], deliver_cancel[]]
  39.  
  40.  
  41.     @action['send_ack'] <<= [payment_recieved[], cancel_order[]]
  42.     @action['cancel'] <<= [action['send_ack'], ack_sended[]]
  43.  
  44.  
  45.  
  46.   end
  47.    
  48.   def tell(fact)
  49.       eval("#{fact.to_s}[].fact") if !ask(fact)
  50.   end
  51.  
  52.   def current_action
  53.     arr =[]
  54.     resolve action[:X] do |env|
  55.       arr << env[:X]
  56.     end
  57.     return arr[-1].to_sym
  58.   end
  59.  
  60.  
  61.   private
  62.   def method_missing(mesh, *args)
  63.     self.class.class_eval { define_method(mesh){ eval("@#{mesh.to_s}")} }
  64.     eval("@#{mesh.to_s}")
  65.   end
  66.    
  67. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top