Module: Saucy::Account
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #admin_emails ⇒ Object
- #expired? ⇒ Boolean
- #has_member?(user) ⇒ Boolean
- #memberships_by_name ⇒ Object
- #past_trial? ⇒ Boolean
- #projects_by_name ⇒ Object
- #projects_count ⇒ Object
- #projects_visible_to(user) ⇒ Object
- #record_new_activations ⇒ Object
- #reset_trial_expiration(length_in_days = nil) ⇒ Object
- #set_trial_expiration ⇒ Object
- #to_param ⇒ Object
- #users_by_name ⇒ Object
- #users_count ⇒ Object
Instance Method Details
#admin_emails ⇒ Object
72 73 74 |
# File 'lib/saucy/account.rb', line 72 def admin_emails admins.map(&:email) end |
#expired? ⇒ Boolean
64 65 66 |
# File 'lib/saucy/account.rb', line 64 def expired? trial? && past_trial? end |
#has_member?(user) ⇒ Boolean
44 45 46 |
# File 'lib/saucy/account.rb', line 44 def has_member?(user) memberships.exists?(:user_id => user.id) end |
#memberships_by_name ⇒ Object
60 61 62 |
# File 'lib/saucy/account.rb', line 60 def memberships_by_name memberships.by_name end |
#past_trial? ⇒ Boolean
68 69 70 |
# File 'lib/saucy/account.rb', line 68 def past_trial? trial_expires_at && trial_expires_at < Time.now end |
#projects_by_name ⇒ Object
52 53 54 |
# File 'lib/saucy/account.rb', line 52 def projects_by_name projects.by_name end |
#projects_count ⇒ Object
103 104 105 |
# File 'lib/saucy/account.rb', line 103 def projects_count projects.active.count end |
#projects_visible_to(user) ⇒ Object
56 57 58 |
# File 'lib/saucy/account.rb', line 56 def projects_visible_to(user) projects.visible_to(user) end |
#record_new_activations ⇒ Object
93 94 95 96 97 |
# File 'lib/saucy/account.rb', line 93 def record_new_activations if activated_changed? && activated? Saucy::Notifications.notify_observers("activated", :account => self) end end |
#reset_trial_expiration(length_in_days = nil) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/saucy/account.rb', line 85 def reset_trial_expiration(length_in_days = nil) new_length = length_in_days || Saucy::Configuration.trial_length new_trial_start_date = [trial_expires_at, Time.zone.now].max self.trial_expires_at = new_length.days.from_now(new_trial_start_date) self.notified_of_completed_trial = false self.notified_of_expiration = false end |
#set_trial_expiration ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/saucy/account.rb', line 76 def set_trial_expiration number_free_days = if coupon 30 * coupon.free_months else Saucy::Configuration.trial_length end self.trial_expires_at = number_free_days.days.from_now(created_at || Time.zone.now) end |
#to_param ⇒ Object
40 41 42 |
# File 'lib/saucy/account.rb', line 40 def to_param keyword end |
#users_by_name ⇒ Object
48 49 50 |
# File 'lib/saucy/account.rb', line 48 def users_by_name users.by_name end |
#users_count ⇒ Object
99 100 101 |
# File 'lib/saucy/account.rb', line 99 def users_count users.count end |