lib/purgatory/purgatory.rb in purgatory-0.2.0 vs lib/purgatory/purgatory.rb in purgatory-1.0.0
- old
+ new
@@ -6,9 +6,20 @@
belongs_to :approver, class_name: 'User'
before_create :store_changes
validates :soul, :requester, presence: true
+ scope :pending, conditions: { approved_at: nil }
+ scope :approved, conditions: ["approved_at IS NOT NULL"]
+
+ def approved?
+ approved_at.present?
+ end
+
+ def pending?
+ approved_at.nil?
+ end
+
def changes_hash
ActiveSupport::JSON.decode(changes_json)
end
def approve!(approver)