Module: Gluttonberg::RecordHistory::ActionController::ControllerHelperClassMethods
- Defined in:
- lib/gluttonberg/record_history.rb
Overview
class methods
Instance Method Summary collapse
- #log_create ⇒ Object
- #log_destroy ⇒ Object
- #log_update ⇒ Object
- #object ⇒ Object
-
#object_title ⇒ Object
this method is used to get title or name for the object.
Instance Method Details
#log_create ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gluttonberg/record_history.rb', line 28 def log_create unless object.blank? if object.new_record? else if object.respond_to?(:user_id) # record creator user id object.user_id = current_user.id object.save end Gluttonberg::Feed.log(current_user, object ,object_title , "created") end end end |
#log_destroy ⇒ Object
49 50 51 52 53 |
# File 'lib/gluttonberg/record_history.rb', line 49 def log_destroy if object && object.destroyed?() Gluttonberg::Feed.log(current_user, object ,object_title , "deleted") end end |
#log_update ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gluttonberg/record_history.rb', line 41 def log_update unless object.blank? if object.errors.blank? Gluttonberg::Feed.log(current_user, object ,object_title , "updated") end end end |
#object ⇒ Object
55 56 57 58 59 |
# File 'lib/gluttonberg/record_history.rb', line 55 def object unless self.class.object_name.blank? self.instance_variable_get(self.class.object_name) end end |
#object_title ⇒ Object
this method is used to get title or name for the object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/gluttonberg/record_history.rb', line 64 def object_title unless object.blank? field_name = "" if self.class.title_field_name.blank? if object.respond_to?(:name) field_name = :name elsif object.respond_to?(:title) field_name = :title elsif object.respond_to?(:title_or_name?) field_name = :title_or_name? else field_name = :id end else field_name = self.class.title_field_name end unless field_name.blank? object.send(field_name) end end end |