module Fingerprints::Extensions::ClassMethods
Public Instance Methods
has_fingerprints(options = {})
click to toggle source
# File lib/fingerprints.rb, line 18 def has_fingerprints(options = {}) options.reverse_merge!(OPTIONS) class_eval <<-"EOV" class << self def fingerprint Thread.current["fingerprint_for_#{self.class}"] end def fingerprint=(val) Thread.current["fingerprint_for_#{self.class}"] = val end end EOV end
leaves_fingerprints(options = {})
click to toggle source
# File lib/fingerprints.rb, line 33 def leaves_fingerprints(options = {}) options.reverse_merge!(OPTIONS) include Fingerprints::Extensions::InstanceMethods belongs_to :creator, :class_name => options[:class_name], :foreign_key => 'created_by' belongs_to :updater, :class_name => options[:class_name], :foreign_key => 'updated_by' before_create :fingerprint_created_by before_update :fingerprint_updated_by define_method('fingerprint_created_by') {|*args| set_fingerprint_for(:created_by, options) } define_method('fingerprint_updated_by') {|*args| set_fingerprint_for(:updated_by, options) } end