Sha256: db8850cfb7e8f0bd747c48517483e9d638da5bade8e82d372282f2c932734800

Contents?: true

Size: 687 Bytes

Versions: 1

Compression:

Stored size: 687 Bytes

Contents

# -*- coding: utf-8 -*-


# Моделька в помощь тем сервисам, что хотят иметь сохраненные сообщения для последующей доставки

class Courier::Message < ActiveRecord::Base
  set_table_name 'courier_messages'

  belongs_to :owner, :polymorphic=>true

  serialize :options, Hash

  scope :fresh, where(:state=>:fresh)
  scope :by_service, lambda { |service| where(:service=>service.to_s) }

  validates_presence_of :owner, :service, :template

  state_machine :state, :initial => :fresh do
    state :fresh
    state :delivered
    event :set_delivered do
      transition :fresh => :delivered
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
courier-0.1.3 lib/courier/message.rb