Sha256: e0335367feabf6262384f13a8c3704463e78e2a8dcd68e67ebe54461819adfb9
Contents?: true
Size: 1.61 KB
Versions: 2
Compression:
Stored size: 1.61 KB
Contents
# -*- encoding : utf-8 -*- module Mongoid module Userstamp extend ActiveSupport::Concern autoload :Version, 'mongoid/userstamp/version' autoload :Railtie, 'mongoid/userstamp/railtie' autoload :Config, 'mongoid/userstamp/config' autoload :User, 'mongoid/userstamp/user' included do include Mongoid::Timestamps field Mongoid::Userstamp.configuration.updated_column, :type => Object field Mongoid::Userstamp.configuration.created_column, :type => Object before_save :set_updator before_create :set_creator define_method Mongoid::Userstamp.configuration.updated_accessor do Mongoid::Userstamp.configuration.user_model.find(self.send(Mongoid::Userstamp.configuration.updated_column)) end define_method Mongoid::Userstamp.configuration.created_accessor do Mongoid::Userstamp.configuration.user_model.find(self.send(Mongoid::Userstamp.configuration.created_column)) end protected def set_updator column = "#{Mongoid::Userstamp.configuration.updated_column.to_s}=".to_sym self.send(column, Mongoid::Userstamp.configuration.user_model.current.try(:id)) end def set_creator column = "#{Mongoid::Userstamp.configuration.created_column.to_s}=".to_sym self.send(column, Mongoid::Userstamp.configuration.user_model.current.try(:id)) end end class << self def configure(&block) @configuration = Mongoid::Userstamp::Config.new(&block) end def configuration @configuration ||= Mongoid::Userstamp::Config.new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mongoid_userstamp-0.1.1 | lib/mongoid/userstamp.rb |
mongoid_userstamp-0.1.0 | lib/mongoid/userstamp.rb |