Class: Cartify::OrderDecorator

Inherits:
Draper::Decorator
  • Object
show all
Defined in:
app/decorator/cartify/order_decorator.rb

Constant Summary collapse

ORDER_STATUSES =
{
  in_progress: I18n.t('order.status.in_progress'),
  in_queue: I18n.t('order.status.in_queue'),
  in_delivery: I18n.t('order.status.in_delivery'),
  delivered: I18n.t('order.status.delivered'),
  canceled: I18n.t('order.status.canceled')
}.freeze

Instance Method Summary collapse

Instance Method Details

#complited_atObject



12
13
14
# File 'app/decorator/cartify/order_decorator.rb', line 12

def complited_at
  object.updated_at.strftime('%F')
end

#creation_dateObject



26
27
28
29
# File 'app/decorator/cartify/order_decorator.rb', line 26

def creation_date
  data = object.updated_at
  I18n.t('date.month_names')[data.month] + " #{data.strftime('%d, %Y')}"
end

#numberObject



16
17
18
19
20
# File 'app/decorator/cartify/order_decorator.rb', line 16

def number
  id = object.id.to_s
  template = 'R0000000'
  template[0..-id.size] + id
end

#secret_card_numberObject



35
36
37
# File 'app/decorator/cartify/order_decorator.rb', line 35

def secret_card_number
  '** ** ** ' + object.credit_card.number.last(4)
end

#sharp_numberObject



31
32
33
# File 'app/decorator/cartify/order_decorator.rb', line 31

def sharp_number
  "#{I18n.t('complete.order')} ##{number}"
end

#statusObject



22
23
24
# File 'app/decorator/cartify/order_decorator.rb', line 22

def status
  ORDER_STATUSES[object.order_status.name.to_sym]
end