Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mark_only.rb

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


63
# File 'lib/mark_only.rb', line 63

def self.mark_only? ; false ; end

Instance Method Details

#mark_only?Boolean

Returns:

  • (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”.

Returns:

  • (Boolean)


69
70
71
# File 'lib/mark_only.rb', line 69

def persisted?
  mark_only? ? !new_record? : super
end