Sha256: 7dbb4c87865da6948139b829f5886820d44d1789dc398a0824813662204b23e4
Contents?: true
Size: 728 Bytes
Versions: 1
Compression:
Stored size: 728 Bytes
Contents
class Purgatory < ActiveRecord::Base attr_accessible :requester, :soul belongs_to :soul, polymorphic: true belongs_to :requester, class_name: 'User' belongs_to :approver, class_name: 'User' before_create :store_changes validates :soul, :requester, presence: true def changes_hash ActiveSupport::JSON.decode(changes_json) end def approve!(approver) return if approved_at.present? changes = changes_hash if soul.update_attributes(changes.update(changes){|k,v| v.last}, without_protection: true) self.approver = approver self.approved_at = Time.now save end end private def store_changes self.changes_json = ActiveSupport::JSON.encode(soul.changes) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
purgatory-0.2.0 | lib/purgatory/purgatory.rb |