Sha256: 18239166fd20f1351da3c82546d98779338f15265221359b60a6abecc050b385
Contents?: true
Size: 780 Bytes
Versions: 1
Compression:
Stored size: 780 Bytes
Contents
class Subscriber < ActiveRecord::Base attr_protected :token scope :active, where("unsubscribed_at IS NULL").order(:name) scope :unsubscribed, where("unsubscribed_at IS NOT NULL").order(:name) validates :name, :presence => true validates :email, :email => true, :uniqueness => true before_create :set_token def active? unsubscribed_at.to_s.empty? end def resubscribe! return true if active? self.unsubscribed_at = nil save end def unsubscribe! return true unless active? self.unsubscribed_at = Time.now save end def email=(value) write_attribute :email, value.strip.downcase end private def set_token write_attribute :token, Digest::SHA1.hexdigest(Time.now.to_s) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree_mail-0.40.0.3 | app/model/subscriber.rb |