lib/purgatory/purgatory.rb in purgatory-4.0.0 vs lib/purgatory/purgatory.rb in purgatory-6.0.0

- old
+ new

@@ -42,25 +42,27 @@ attr_accessor_fields.each{|k,v| soul.instance_variable_set(k, v)} if attr_accessor_fields soul end def approve!(approver = nil) + return false if approved? + + success = nil self.with_lock do - return false if approved? success = soul_with_changes.save if performable_method.present? && success - success = soul.send(performable_method[:method],*performable_method[:args]) + success = soul.send(performable_method[:method], *performable_method[:args]) end if success self.approver = approver self.approved_at = Time.now self.soul_id = soul.id save - return true end - false end + + success end def self.pending_with_matching_soul(soul) pending.where("soul_id IS NOT NULL AND soul_id = ? AND soul_type = ?", soul.id, soul.class.base_class.name) end