Module: Comable::ApplicationHelper
- Included in:
- OrderMailer
- Defined in:
- app/helpers/comable/application_helper.rb
Instance Method Summary collapse
- #current_comable_user ⇒ Object
- #current_navigations ⇒ Object
- #current_order ⇒ Object
- #current_store ⇒ Object
- #current_trackers ⇒ Object
-
#liquid_assigns ⇒ Object
To use the functionality of liquid-rails.
- #liquidize(content, arguments) ⇒ Object
- #name_with_honorific(name) ⇒ Object
- #name_with_quantity(name, quantity) ⇒ Object
- #next_order_path ⇒ Object
- #page_name ⇒ Object
- #store_location ⇒ Object
- #update_order_path ⇒ Object
Instance Method Details
#current_comable_user ⇒ Object
7 8 9 10 11 12 |
# File 'app/helpers/comable/application_helper.rb', line 7 def current_comable_user resource = current_admin_user if defined? Comable::Backend resource ||= current_user if defined? Comable::Frontend resource ||= Comable::User.new resource.() end |
#current_navigations ⇒ Object
22 23 24 |
# File 'app/helpers/comable/application_helper.rb', line 22 def @current_navigations ||= Comable::Navigation.all end |
#current_order ⇒ Object
14 15 16 |
# File 'app/helpers/comable/application_helper.rb', line 14 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
18 19 20 |
# File 'app/helpers/comable/application_helper.rb', line 18 def current_trackers @curent_trackers ||= (controller_name == 'orders' && action_name == 'create') ? Comable::Tracker.activated : Comable::Tracker.activated.with_place(:everywhere) end |
#liquid_assigns ⇒ Object
To use the functionality of liquid-rails
58 59 60 61 62 63 64 65 66 |
# File 'app/helpers/comable/application_helper.rb', line 58 def liquid_assigns view_context.assigns.merge( current_store: current_store, current_comable_user: current_comable_user, current_order: current_order, current_trackers: current_trackers, form_authenticity_token: form_authenticity_token ).stringify_keys end |
#liquidize(content, arguments) ⇒ Object
52 53 54 55 |
# File 'app/helpers/comable/application_helper.rb', line 52 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
39 40 41 |
# File 'app/helpers/comable/application_helper.rb', line 39 def name_with_honorific(name) Comable.t('honorific', name: name) end |
#name_with_quantity(name, quantity) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/helpers/comable/application_helper.rb', line 43 def name_with_quantity(name, quantity) return name unless quantity return name if quantity <= 1 [ name, "x#{quantity}" ].join(' ') end |
#next_order_path ⇒ Object
26 27 28 |
# File 'app/helpers/comable/application_helper.rb', line 26 def next_order_path comable.next_order_path(state: current_order.state) end |
#page_name ⇒ Object
68 69 70 |
# File 'app/helpers/comable/application_helper.rb', line 68 def page_name [controller_name, action_name].join(':') end |
#store_location ⇒ Object
35 36 37 |
# File 'app/helpers/comable/application_helper.rb', line 35 def store_location session[:user_return_to] = request.fullpath.gsub('//', '/') end |
#update_order_path ⇒ Object
30 31 32 33 |
# File 'app/helpers/comable/application_helper.rb', line 30 def update_order_path return next_order_path unless params[:state] comable.next_order_path(state: params[:state]) end |