Class: Pravangi::PendingApproval
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pravangi::PendingApproval
- Defined in:
- lib/pravangi/models/pending_approval.rb
Instance Method Summary collapse
- #approve_changes ⇒ Object
- #as_object ⇒ Object
- #changed_object_attributes ⇒ Object
- #reject_changes ⇒ Object
- #skip_attributes ⇒ Object
Instance Method Details
#approve_changes ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/pravangi/models/pending_approval.rb', line 20 def approve_changes PendingApproval.transaction do resource.skip_approval = true object_changes.each do |k,v| resource[k] = v[1] end self.update_attribute(:is_approved, true) resource.save resource.reload end end |
#as_object ⇒ Object
12 13 14 |
# File 'lib/pravangi/models/pending_approval.rb', line 12 def as_object @object ||= YAML.load(raw_object) end |
#changed_object_attributes ⇒ Object
16 17 18 |
# File 'lib/pravangi/models/pending_approval.rb', line 16 def changed_object_attributes self.object_changes.keys end |
#reject_changes ⇒ Object
32 33 34 |
# File 'lib/pravangi/models/pending_approval.rb', line 32 def reject_changes self.update_attribute(:is_rejected, true) end |
#skip_attributes ⇒ Object
36 37 38 39 40 |
# File 'lib/pravangi/models/pending_approval.rb', line 36 def skip_attributes if self.resource.class.[:skip_attributes] object_changes.except(*self.resource.class.[:skip_attributes]) end end |