Module: Mongoid::Userstamp
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid/userstamp.rb,
lib/mongoid/userstamp/user.rb,
lib/mongoid/userstamp/config.rb,
lib/mongoid/userstamp/railtie.rb,
lib/mongoid/userstamp/version.rb
Defined Under Namespace
Modules: User
Classes: Config, Railtie
Constant Summary
collapse
- VERSION =
'0.10.0'
Class Method Summary
collapse
Class Method Details
.config(&block) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/mongoid/userstamp.rb', line 26
def config(&block)
if block_given?
@@config = Userstamp::Config.new(&block)
else
@@config ||= Userstamp::Config.new
end
end
|
.current_user ⇒ Object
38
39
40
|
# File 'lib/mongoid/userstamp.rb', line 38
def current_user
config.user_model.try(:current)
end
|
.find_user(user_id) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/mongoid/userstamp.rb', line 42
def find_user(user_id)
begin
user_id ? Userstamp.config.user_model.unscoped.find(user_id) : nil
rescue Mongoid::Errors::DocumentNotFound => e
nil
end
end
|
.has_current_user? ⇒ Boolean
34
35
36
|
# File 'lib/mongoid/userstamp.rb', line 34
def has_current_user?
config.user_model.respond_to?(:current)
end
|