Module: EffectiveTrash
- Includes:
- EffectiveGem
- Defined in:
- lib/generators/effective_trash/trash_archived_booleans_generator.rb,
lib/effective_trash.rb,
lib/effective_trash/engine.rb,
lib/effective_trash/version.rb,
lib/effective_trash/set_current_user.rb,
lib/generators/effective_trash/install_generator.rb
Overview
bundle exec rails generate effective_trash:trash_archived_booleans
Defined Under Namespace
Modules: Generators, SetCurrentUser Classes: Engine
Constant Summary collapse
- VERSION =
'0.4.5'.freeze
Class Method Summary collapse
- .config_keys ⇒ Object
- .current_user ⇒ Object
-
.current_user=(user) ⇒ Object
This is set by the “set_effective_trash_current_user” before_filter.
-
.trash!(obj) ⇒ Object
Trash it - Does not delete the original object.
Class Method Details
.config_keys ⇒ Object
7 8 9 10 11 |
# File 'lib/effective_trash.rb', line 7 def self.config_keys [ :trash_table_name, :layout, :routes_enabled ] end |
.current_user ⇒ Object
20 21 22 |
# File 'lib/effective_trash.rb', line 20 def self.current_user @effective_trash_current_user end |
.current_user=(user) ⇒ Object
This is set by the “set_effective_trash_current_user” before_filter.
16 17 18 |
# File 'lib/effective_trash.rb', line 16 def self.current_user=(user) @effective_trash_current_user = user end |
.trash!(obj) ⇒ Object
Trash it - Does not delete the original object. This is run in a before_destroy, or through a script.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/effective_trash.rb', line 26 def self.trash!(obj) args = (obj.respond_to?(:acts_as_trashable_options) ? obj. : {}) details = Effective::Resource.new(obj).instance_attributes(only: args[:only], except: args[:except]) trash = Effective::Trash.new( trashed: obj, user: EffectiveTrash.current_user, trashed_to_s: obj.to_s, trashed_extra: obj.try(:trashed_extra), details: details ).save! end |