Module: RightnowOms::ControllerExtension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/rightnow_oms/controller_extension.rb
Instance Method Summary collapse
- #has_cart? ⇒ Boolean
- #load_cart(key = nil) ⇒ Object
- #load_or_create_cart(name = nil) ⇒ Object
- #remove_null_params(data = params) ⇒ Object
Instance Method Details
#has_cart? ⇒ Boolean
5 6 7 |
# File 'lib/rightnow_oms/controller_extension.rb', line 5 def has_cart? !@cart.nil? end |
#load_cart(key = nil) ⇒ Object
16 17 18 19 |
# File 'lib/rightnow_oms/controller_extension.rb', line 16 def load_cart(key = nil) key ||= :current_cart_id @cart = RightnowOms::Cart.find_by_id(session[key]) end |
#load_or_create_cart(name = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rightnow_oms/controller_extension.rb', line 21 def load_or_create_cart(name = nil) key = name ? "#{name}_cart_id".to_sym : :current_cart_id load_cart key unless has_cart? @cart = RightnowOms::Cart.create end session[:current_cart_id] = session[key] = @cart.id end |
#remove_null_params(data = params) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/rightnow_oms/controller_extension.rb', line 9 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 |