Sha256: 8b745e0abdb6e051e77e73bf9667a0873f92fe2b961fee9b6a4999333970f4a3

Contents?: true

Size: 557 Bytes

Versions: 4

Compression:

Stored size: 557 Bytes

Contents

module RightnowOms
  module ControllerHelpers
    extend ActiveSupport::Concern

    def has_cart?
      !@cart.nil?
    end

    def load_or_create_cart
      load_cart

      unless has_cart?
        @cart = RightnowOms::Cart.create! and session[:cart_id] = @cart.id
      end
    end

    def load_cart
      @cart = RightnowOms::Cart.find_by_id(session[:cart_id])
    end

    def remove_null_params(data = params)
      data.each do |k, v|
        remove_null_params(v) if v.is_a? Hash
        data.delete(k) if v == 'null'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rightnow_oms-0.1.4 lib/rightnow_oms/controller_helpers.rb
rightnow_oms-0.1.3 lib/rightnow_oms/controller_helpers.rb
rightnow_oms-0.1.2 lib/rightnow_oms/controller_helpers.rb
rightnow_oms-0.1.1 lib/rightnow_oms/controller_helpers.rb