class ActiveRecord::Base

Public Class Methods

mark_only(col_name) click to toggle source
# File lib/mark_only.rb, line 122
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
  class << self
    alias_method :mark_only_orig_class_delete, :delete
    alias_method :mark_only_orig_class_delete_all, :delete_all
  end
  alias_method :mark_only_orig_delete, :delete
  alias_method :mark_only_orig_destroy, :destroy
  alias_method :mark_only_orig_destroyed?, :destroyed?
  include MarkOnly
  if defined?(ActiveRecord::VERSION::MAJOR) && ActiveRecord::VERSION::MAJOR > 3
    alias_method :mark_only_orig_destroy!, :destroy!
    include MarkOnlyRails4Extensions
  end
end
mark_only?() click to toggle source
# File lib/mark_only.rb, line 140
def self.mark_only?
  false
end

Public Instance Methods

mark_only?() click to toggle source
# File lib/mark_only.rb, line 144
def mark_only?
  self.class.mark_only?
end
persisted?() click to toggle source
Calls superclass method
# File lib/mark_only.rb, line 148
def persisted?
  mark_only? ? !new_record? : super
end

Private Instance Methods

update_mark_only_attribute_or_column(*args) click to toggle source

Rails 3.1 adds update_column. Rails > 3.2.6 deprecates update_attribute, gone in Rails 4.

# File lib/mark_only.rb, line 155
def update_mark_only_attribute_or_column(*args)
  respond_to?(:update_column) ? update_column(*args) : update_attribute(*args)
end