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.41 app/models/suspendable.rb
fullstack-admin-0.1.40 app/models/suspendable.rb
fullstack-admin-0.1.39 app/models/suspendable.rb
fullstack-admin-0.1.38 app/models/suspendable.rb
fullstack-admin-0.1.37 app/models/suspendable.rb
fullstack-admin-0.1.36 app/models/suspendable.rb
fullstack-admin-0.1.35 app/models/suspendable.rb
fullstack-admin-0.1.34 app/models/suspendable.rb
fullstack-admin-0.1.33 app/models/suspendable.rb
fullstack-admin-0.1.32 app/models/suspendable.rb
fullstack-admin-0.1.30 app/models/suspendable.rb
fullstack-admin-0.1.29 app/models/suspendable.rb
fullstack-admin-0.1.28 app/models/suspendable.rb
fullstack-admin-0.1.27 app/models/suspendable.rb
fullstack-admin-0.1.26 app/models/suspendable.rb
fullstack-admin-0.1.25 app/models/suspendable.rb
fullstack-admin-0.1.24 app/models/suspendable.rb
fullstack-admin-0.1.23 app/models/suspendable.rb
fullstack-admin-0.1.20 app/models/suspendable.rb
fullstack-admin-0.1.19 app/models/suspendable.rb