Sha256: 685b7aa5e20776f19b320fc0d2c7374173783a39bd05c9560e9f11426bc1c22a

Contents?: true

Size: 491 Bytes

Versions: 73

Compression:

Stored size: 491 Bytes

Contents

module Suspendable
  extend ActiveSupport::Concern
  
  included do
    field :suspended_at, :as => :datetime
    scope :suspended, where("suspended_at IS NULL")
  end
  
  def active?
    super && !suspended? 
  end 

  def inactive_message 
    !suspended? ? super : :suspended 
  end 

  def suspend!
    update_attributes(:suspended_at => Time.now.utc) 
  end 

  def unsuspend! 
    update_attributes(:suspended_at => nil) 
  end 

  def suspended? 
    !suspended_at.nil? 
  end
  
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
fullstack-admin-0.1.18 app/models/suspendable.rb
fullstack-admin-0.1.17 app/models/suspendable.rb
fullstack-admin-0.1.16 app/models/suspendable.rb
fullstack-admin-0.1.15 app/models/suspendable.rb
fullstack-admin-0.1.14 app/models/suspendable.rb
fullstack-admin-0.1.12 app/models/suspendable.rb
fullstack-admin-0.1.11 app/models/suspendable.rb
fullstack-admin-0.1.10 app/models/suspendable.rb
fullstack-admin-0.1.8 app/models/suspendable.rb
fullstack-admin-0.1.7 app/models/suspendable.rb
fullstack-admin-0.1.5 app/models/suspendable.rb
fullstack-admin-0.1.3 app/models/suspendable.rb
fullstack-admin-0.1.1 app/models/suspendable.rb