Module: Stall::CustomersHelper

Defined in:
app/helpers/stall/customers_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_stall_userObject



7
8
9
10
11
# File 'app/helpers/stall/customers_helper.rb', line 7

def current_stall_user
  if (method = Stall.config.default_user_helper_method) && respond_to?(method, true)
    send(Stall.config.default_user_helper_method)
  end
end

#stall_user_signed_in?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'app/helpers/stall/customers_helper.rb', line 3

def stall_user_signed_in?
  !!current_stall_user
end

#with_errors_from_user(customer) ⇒ Object

Copy e-mail error messages from user to customer, allowing them to be displayed in customer e-mail input to the visitor



16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/stall/customers_helper.rb', line 16

def with_errors_from_user(customer)
  return customer unless (user = customer.user) && user.errors.any?
  return unless (messages = user.errors.messages[:email]) && messages.any?

  messages.each do |message|
    customer.errors.add(:email, message)
  end

  customer
end