Class: Workarea::Storefront::UserViewModel

Inherits:
ApplicationViewModel
  • Object
show all
Defined in:
app/view_models/workarea/storefront/user_view_model.rb

Instance Method Summary collapse

Instance Method Details

#credit_cardsObject



18
19
20
# File 'app/view_models/workarea/storefront/user_view_model.rb', line 18

def credit_cards
  payment.credit_cards
end

#default_credit_cardObject



10
11
12
# File 'app/view_models/workarea/storefront/user_view_model.rb', line 10

def default_credit_card
  @default_credit_card ||= payment.default_credit_card
end

#email_signup?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'app/view_models/workarea/storefront/user_view_model.rb', line 31

def email_signup?
  return @email_signup if defined?(@email_signup)
  @email_signup = Email.signed_up?(email)
end

#has_credit_card?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/view_models/workarea/storefront/user_view_model.rb', line 14

def has_credit_card?
  !!default_credit_card
end

#has_default_addresses?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'app/view_models/workarea/storefront/user_view_model.rb', line 6

def has_default_addresses?
  addresses.present?
end

#recent_ordersObject



22
23
24
25
26
27
28
29
# File 'app/view_models/workarea/storefront/user_view_model.rb', line 22

def recent_orders
  @recent_orders ||= recent_order_models.map do |order|
    Storefront::OrderViewModel.new(
      order,
      fulfillment_status: fulfillment_statuses[order.id]
    )
  end
end