Sha256: 5d1bd22dc13a59669db6d206a217db03ce91bd7aa351415f6082a64b613dd85b
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
module ActsAsTrashable extend ActiveSupport::Concern module ActiveRecord def acts_as_trashable(*options) @acts_as_trashable_options = options.try(:first) || {} unless @acts_as_trashable_options.kind_of?(Hash) raise ArgumentError.new("invalid arguments passed to (effective_trash) acts_as_trashable. Expecting no options.") end include ::ActsAsTrashable end end included do has_one :trash, as: :trashed, class_name: 'Effective::Trash' before_destroy do EffectiveTrash.trash!(self) end # Parse Options acts_as_trashable_options = { only: Array(@acts_as_trashable_options[:only]).map { |attribute| attribute.to_s }, except: Array(@acts_as_trashable_options[:except]).map { |attribute| attribute.to_s }, additionally: Array(@acts_as_trashable_options[:additionally]).map { |attribute| attribute.to_s } } self.send(:define_method, :acts_as_trashable_options) { acts_as_trashable_options } end module ClassMethods end # Regular instance methods end
Version data entries
5 entries across 5 versions & 1 rubygems