Sha256: ab27bb71487445a6e2e278f54da3d6034ea1dc45b46ac633316b97985c1a1b61

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

module Shop
  module Controllers
    module ApplicationController
      
      def self.included(base)
        base.class_eval do
          filter_parameter_logging :password, :password_confirmation, :credit
          
          def current_shop_order
            return @current_shop_order if defined?(@current_shop_order)
            @current_shop_order = find_or_create_shop_order if request.session[:shop_order]
          end
          
          def find_shop_order
            shop_order = nil
            
            begin
              shop_order = ShopOrder.find(request.session[:shop_order])
            rescue
              shop_order = nil
            end
                        
            shop_order
          end
          
          def find_or_create_shop_order
            shop_order = nil
            
            if find_shop_order
              shop_order = find_shop_order
            else
              shop_order = ShopOrder.create({ :customer_id => (current_user.id rescue nil) })
              request.session[:shop_order] = shop_order.id
            end
            
            shop_order
          end
        end
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
radiant-shop-extension-0.92.1 lib/shop/controllers/application_controller.rb
radiant-shop-extension-0.92.0 lib/shop/controllers/application_controller.rb
radiant-shop-extension-0.91.7 lib/shop/controllers/application_controller.rb
radiant-shop-extension-0.91.4 lib/shop/controllers/application_controller.rb
radiant-shop-extension-0.91.3 lib/shop/controllers/application_controller.rb
radiant-shop-extension-0.91.2 lib/shop/controllers/application_controller.rb