Class: FlowChat::Ussd::Processor
- Inherits:
-
Object
- Object
- FlowChat::Ussd::Processor
- Defined in:
- lib/flow_chat/ussd/processor.rb
Instance Attribute Summary collapse
-
#gateway ⇒ Object
readonly
Returns the value of attribute gateway.
-
#middleware ⇒ Object
readonly
Returns the value of attribute middleware.
Instance Method Summary collapse
-
#initialize(controller) {|_self| ... } ⇒ Processor
constructor
A new instance of Processor.
- #run(flow_class, action) {|stack| ... } ⇒ Object
- #use_gateway(gateway) ⇒ Object
- #use_middleware(middleware) ⇒ Object
- #use_resumable_sessions ⇒ Object
- #use_session_store(session_store) ⇒ Object
Constructor Details
#initialize(controller) {|_self| ... } ⇒ Processor
Returns a new instance of Processor.
8 9 10 11 12 13 14 |
# File 'lib/flow_chat/ussd/processor.rb', line 8 def initialize(controller) @context = FlowChat::Context.new @context["controller"] = controller @middleware = ::Middleware::Builder.new(name: "ussd.middleware") yield self if block_given? end |
Instance Attribute Details
#gateway ⇒ Object (readonly)
Returns the value of attribute gateway.
6 7 8 |
# File 'lib/flow_chat/ussd/processor.rb', line 6 def gateway @gateway end |
#middleware ⇒ Object (readonly)
Returns the value of attribute middleware.
6 7 8 |
# File 'lib/flow_chat/ussd/processor.rb', line 6 def middleware @middleware end |
Instance Method Details
#run(flow_class, action) {|stack| ... } ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/flow_chat/ussd/processor.rb', line 36 def run(flow_class, action) @context["flow.name"] = flow_class.name.underscore @context["flow.class"] = flow_class @context["flow.action"] = action stack = ::Middleware::Builder.new name: "ussd" do |b| b.use gateway b.use FlowChat::Session::Middleware b.use FlowChat::Ussd::Middleware::Pagination b.use middleware b.use FlowChat::Ussd::Middleware::Executor end.inject_logger(Rails.logger) yield stack if block_given? stack.call(@context) end |
#use_gateway(gateway) ⇒ Object
16 17 18 19 |
# File 'lib/flow_chat/ussd/processor.rb', line 16 def use_gateway(gateway) @gateway = gateway self end |
#use_middleware(middleware) ⇒ Object
26 27 28 29 |
# File 'lib/flow_chat/ussd/processor.rb', line 26 def use_middleware(middleware) @middleware.use middleware self end |
#use_resumable_sessions ⇒ Object
31 32 33 34 |
# File 'lib/flow_chat/ussd/processor.rb', line 31 def use_resumable_sessions middleware.insert_before 0, FlowChat::Ussd::Middleware::ResumableSession self end |
#use_session_store(session_store) ⇒ Object
21 22 23 24 |
# File 'lib/flow_chat/ussd/processor.rb', line 21 def use_session_store(session_store) @context["session.store"] = session_store self end |