Class: Opensteam::Checkout::CheckoutFlowController

Inherits:
ShoppingCart::CartController show all
Defined in:
lib/opensteam/checkout.rb

Instance Method Summary collapse

Methods inherited from ShoppingCart::CartController

#add_inventory_to_cart, #decr_quantity, #del_item, #empty_cart, #incr_quantity, #show_cart_item, #update_quantity

Instance Method Details

#create_checkout_flow(target = self) {|target| ... } ⇒ Object

create the checkout flow

define an init-method in your CheckoutController:

def init
  create_checkout_flow do |c|
    c.on :start, :intro
    c.on :finish, :controller => "petstore", :action => "index"
  end
end

Yields:

  • (target)


51
52
53
# File 'lib/opensteam/checkout.rb', line 51

def create_checkout_flow( target = self )
  yield target if block_given?
end

#current_stepObject

save the current-action name in the sessions



30
31
32
# File 'lib/opensteam/checkout.rb', line 30

def current_step
  session[:current_action] = self.action_name
end

#endstepObject

method to finish the checkout-process and redirect_to the action specified by :finish



37
38
39
# File 'lib/opensteam/checkout.rb', line 37

def endstep
  redirect_to_step(:finish)
end

#invokeObject

start the checkout process and redirect_to the action specified by :start



58
59
60
# File 'lib/opensteam/checkout.rb', line 58

def invoke
  redirect_to_step(:start)
end

#on(sym, hash) ⇒ Object

define a flow step

on :start, :intro
on :finish, :controller => "webshop", :action => "index"


67
68
69
# File 'lib/opensteam/checkout.rb', line 67

def on(sym, hash)
  steps.store( sym, hash )
end