Class: RailsAdmin::Extensions::MongoidAudit::AuditingAdapter
- Inherits:
-
Object
- Object
- RailsAdmin::Extensions::MongoidAudit::AuditingAdapter
- Defined in:
- lib/mongoid-audit/rails_admin.rb
Constant Summary collapse
- COLUMN_MAPPING =
{ :table => 'association_chain.name', :username => 'modifier_id', :item => 'association_chain.id', :created_at => :created_at, :message => :action }
Instance Method Summary collapse
- #create_object(object, abstract_model, user) ⇒ Object
- #delete_object(object, model, user) ⇒ Object
-
#initialize(controller, version_class = HistoryTracker) ⇒ AuditingAdapter
constructor
A new instance of AuditingAdapter.
- #latest(include_empty_modifier = false) ⇒ Object
- #listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20)) ⇒ Object
- #listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20)) ⇒ Object
- #update_object(object, model, user, changes) ⇒ Object
Constructor Details
#initialize(controller, version_class = HistoryTracker) ⇒ AuditingAdapter
Returns a new instance of AuditingAdapter.
69 70 71 72 |
# File 'lib/mongoid-audit/rails_admin.rb', line 69 def initialize(controller, version_class = HistoryTracker) @controller = controller @version_class = version_class.to_s.constantize end |
Instance Method Details
#create_object(object, abstract_model, user) ⇒ Object
91 92 93 |
# File 'lib/mongoid-audit/rails_admin.rb', line 91 def create_object(object, abstract_model, user) # do nothing end |
#delete_object(object, model, user) ⇒ Object
83 84 85 |
# File 'lib/mongoid-audit/rails_admin.rb', line 83 def delete_object(object, model, user) # do nothing end |
#latest(include_empty_modifier = false) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/mongoid-audit/rails_admin.rb', line 74 def latest(include_empty_modifier = false) versions = @version_class unless include_empty_modifier versions.where(:updater_id.exists => true) end versions = versions.desc(:_id).limit(20) versions.map { |version| VersionProxy.new(version) } end |
#listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20)) ⇒ Object
95 96 97 |
# File 'lib/mongoid-audit/rails_admin.rb', line 95 def listing_for_model(model, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20)) listing_for_model_or_object(model, nil, query, sort, sort_reverse, all, page, per_page) end |
#listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20)) ⇒ Object
99 100 101 |
# File 'lib/mongoid-audit/rails_admin.rb', line 99 def listing_for_object(model, object, query, sort, sort_reverse, all, page, per_page = (RailsAdmin::Config.default_items_per_page || 20)) listing_for_model_or_object(model, object, query, sort, sort_reverse, all, page, per_page) end |
#update_object(object, model, user, changes) ⇒ Object
87 88 89 |
# File 'lib/mongoid-audit/rails_admin.rb', line 87 def update_object(object, model, user, changes) # do nothing end |