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.2.26 app/models/suspendable.rb
fullstack-admin-0.2.25 app/models/suspendable.rb
fullstack-admin-0.2.24 app/models/suspendable.rb
fullstack-admin-0.2.23 app/models/suspendable.rb
fullstack-admin-0.2.22 app/models/suspendable.rb
fullstack-admin-0.2.21 app/models/suspendable.rb
fullstack-admin-0.2.20 app/models/suspendable.rb
fullstack-admin-0.2.19 app/models/suspendable.rb
fullstack-admin-0.2.18 app/models/suspendable.rb
fullstack-admin-0.2.17 app/models/suspendable.rb
fullstack-admin-0.2.16 app/models/suspendable.rb
fullstack-admin-0.2.15 app/models/suspendable.rb
fullstack-admin-0.2.14 app/models/suspendable.rb
fullstack-admin-0.2.13 app/models/suspendable.rb
fullstack-admin-0.2.12 app/models/suspendable.rb
fullstack-admin-0.2.11 app/models/suspendable.rb
fullstack-admin-0.2.9 app/models/suspendable.rb
fullstack-admin-0.2.8 app/models/suspendable.rb
fullstack-admin-0.2.7 app/models/suspendable.rb
fullstack-admin-0.2.6 app/models/suspendable.rb