Module: Comable::ApplicationHelper
- Included in:
- OrderMailer
- Defined in:
- app/helpers/comable/application_helper.rb
Instance Method Summary collapse
- #current_comable_user ⇒ Object
- #current_order ⇒ Object
- #current_store ⇒ Object
- #current_trackers ⇒ Object
- #liquidize(content, arguments) ⇒ Object
- #name_with_honorific(name) ⇒ Object
- #name_with_quantity(name, quantity) ⇒ Object
- #next_order_path ⇒ Object
- #store_location ⇒ Object
- #update_order_path ⇒ Object
Instance Method Details
#current_comable_user ⇒ Object
7 8 9 10 |
# File 'app/helpers/comable/application_helper.rb', line 7 def current_comable_user resource = current_admin_user || current_user || Comable::User.new resource.() end |
#current_order ⇒ Object
12 13 14 |
# File 'app/helpers/comable/application_helper.rb', line 12 def current_order current_comable_user.incomplete_order end |
#current_store ⇒ Object
3 4 5 |
# File 'app/helpers/comable/application_helper.rb', line 3 def current_store @current_store ||= Comable::Store.instance end |
#current_trackers ⇒ Object
16 17 18 |
# File 'app/helpers/comable/application_helper.rb', line 16 def current_trackers @curent_trackers ||= (controller_name == 'orders' && action_name == 'create') ? Comable::Tracker.activated : Comable::Tracker.activated.with_place(:everywhere) end |
#liquidize(content, arguments) ⇒ Object
46 47 48 49 |
# File 'app/helpers/comable/application_helper.rb', line 46 def liquidize(content, arguments) string = Liquid::Template.parse(content).render(arguments.stringify_keys) string.respond_to?(:html_safe) ? string.html_safe : string end |
#name_with_honorific(name) ⇒ Object
33 34 35 |
# File 'app/helpers/comable/application_helper.rb', line 33 def name_with_honorific(name) Comable.t('honorific', name: name) end |
#name_with_quantity(name, quantity) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/helpers/comable/application_helper.rb', line 37 def name_with_quantity(name, quantity) return name unless quantity return name if quantity <= 1 [ name, "x#{quantity}" ].join(' ') end |
#next_order_path ⇒ Object
20 21 22 |
# File 'app/helpers/comable/application_helper.rb', line 20 def next_order_path comable.next_order_path(state: current_order.state) end |
#store_location ⇒ Object
29 30 31 |
# File 'app/helpers/comable/application_helper.rb', line 29 def store_location session[:user_return_to] = request.fullpath.gsub('//', '/') end |
#update_order_path ⇒ Object
24 25 26 27 |
# File 'app/helpers/comable/application_helper.rb', line 24 def update_order_path return next_order_path unless params[:state] comable.next_order_path(state: params[:state]) end |