Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/mark_only.rb
Class Method Summary collapse
Instance Method Summary collapse
- #mark_only? ⇒ Boolean
-
#persisted? ⇒ Boolean
Override the persisted method to allow for the paranoia gem.
Class Method Details
.mark_only(col_name) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/mark_only.rb', line 54 def self.mark_only(col_name) raise "#{self} must call mark_only with a column name!" unless col_name class_attribute :mark_only_column, instance_writer: true self.mark_only_column = col_name.to_sym alias :destroy! :destroy alias :delete! :delete include MarkOnly end |
.mark_only? ⇒ Boolean
63 |
# File 'lib/mark_only.rb', line 63 def self.mark_only? ; false ; end |
Instance Method Details
#mark_only? ⇒ Boolean
64 |
# File 'lib/mark_only.rb', line 64 def mark_only? ; self.class.mark_only? ; end |
#persisted? ⇒ Boolean
Override the persisted method to allow for the paranoia gem. If a mark_only record is selected, then we only want to check if it’s a new record, not if it is “destroyed”.
69 70 71 |
# File 'lib/mark_only.rb', line 69 def persisted? mark_only? ? !new_record? : super end |