Class: AnonymousShadowCreator
- Inherits:
-
Object
- Object
- AnonymousShadowCreator
- Defined in:
- app/services/anonymous_shadow_creator.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #get ⇒ Object
- #get_master ⇒ Object
-
#initialize(user) ⇒ AnonymousShadowCreator
constructor
A new instance of AnonymousShadowCreator.
Constructor Details
#initialize(user) ⇒ AnonymousShadowCreator
Returns a new instance of AnonymousShadowCreator.
14 15 16 |
# File 'app/services/anonymous_shadow_creator.rb', line 14 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'app/services/anonymous_shadow_creator.rb', line 4 def user @user end |
Class Method Details
.get(user) ⇒ Object
10 11 12 |
# File 'app/services/anonymous_shadow_creator.rb', line 10 def self.get(user) new(user).get end |
.get_master(user) ⇒ Object
6 7 8 |
# File 'app/services/anonymous_shadow_creator.rb', line 6 def self.get_master(user) new(user).get_master end |
Instance Method Details
#get ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/services/anonymous_shadow_creator.rb', line 25 def get return unless user return unless SiteSetting.allow_anonymous_posting return if !user.in_any_groups?(SiteSetting.anonymous_posting_allowed_groups_map) return if SiteSetting.must_approve_users? && !user.approved? shadow = user.shadow_user if shadow && (shadow.post_count + shadow.topic_count) > 0 && shadow.last_posted_at && shadow.last_posted_at < SiteSetting.anonymous_account_duration_minutes.minutes.ago shadow = nil end shadow || create_shadow! end |
#get_master ⇒ Object
18 19 20 21 22 23 |
# File 'app/services/anonymous_shadow_creator.rb', line 18 def get_master return unless user return unless SiteSetting.allow_anonymous_posting user.master_user end |