module Millstone::ActiveRecord::Extension::ClassMethods
Public Instance Methods
as_millstone?()
click to toggle source
# File lib/millstone/active_record/extension.rb, line 21 def as_millstone? self.included_modules.include?(InstanceMethods) end
millstone(options = {})
click to toggle source
# File lib/millstone/active_record/extension.rb, line 25 def millstone(options = {}) options = options.reverse_merge(:column => :deleted_at, :type => :time) unless [:time, :boolean].include? options[:type] raise ArgumentError, "'time' or 'boolean' expected for :type option, got #{options[:type]}" end class_attribute :millstone_configuration, :millstone_column_reference self.millstone_configuration = options self.millstone_column_reference = "#{self.table_name}.#{millstone_configuration[:column]}" return if as_millstone? extend ClassMethods include InstanceMethods include Validations self.class_eval do alias_method :paranoid_value, :millstone_column_value end class << self delegate :destroy!, :destroy_all!, :delete!, :delete_all!, :to => :scoped delegate :with_deleted, :only_deleted, :to => :scoped alias_method_chain :relation, :millstone # for acts_as_paranoid alias_method :paranoid_column, :millstone_column alias_method :paranoid_column_type, :millstone_type alias_method :paranoid_column_reference, :millstone_column_reference alias_method :paranoid_configuration, :millstone_configuration end end