Sha256: d533a0bd2dfcf08976d46ac67d85c7620840163b8a91ba0f6609975d9fcdead6

Contents?: true

Size: 529 Bytes

Versions: 4

Compression:

Stored size: 529 Bytes

Contents

module Workarea
  class InventoryNotification
    include ApplicationDocument

    field :product_id,  type: String
    field :sku,         type: String
    field :email,       type: String
    field :sent_at,     type: DateTime

    validates :product_id, presence: true
    validates :sku, presence: true
    validates :email, presence: true,
                      email: true

    index(sku: 1)

    scope :unsent, -> { where(sent_at: nil) }

    def mark_as_sent!
      update_attributes(sent_at: Time.now)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-inventory_notifications-2.1.5 app/models/workarea/inventory_notification.rb
workarea-inventory_notifications-2.1.4 app/models/workarea/inventory_notification.rb
workarea-inventory_notifications-2.1.3 app/models/workarea/inventory_notification.rb
workarea-inventory_notifications-2.1.2 app/models/workarea/inventory_notification.rb