Module: Saucy::Account

Extended by:
ActiveSupport::Concern
Included in:
Account
Defined in:
lib/saucy/account.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#admin_emailsObject



72
73
74
# File 'lib/saucy/account.rb', line 72

def admin_emails
  admins.map(&:email)
end

#expired?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/saucy/account.rb', line 64

def expired?
  trial? && past_trial?
end

#has_member?(user) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/saucy/account.rb', line 44

def has_member?(user)
  memberships.exists?(:user_id => user.id)
end

#memberships_by_nameObject



60
61
62
# File 'lib/saucy/account.rb', line 60

def memberships_by_name
  memberships.by_name
end

#past_trial?Boolean

Returns:

  • (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_nameObject



52
53
54
# File 'lib/saucy/account.rb', line 52

def projects_by_name
  projects.by_name
end

#projects_countObject



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_activationsObject



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_expirationObject



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_paramObject



40
41
42
# File 'lib/saucy/account.rb', line 40

def to_param
  keyword
end

#users_by_nameObject



48
49
50
# File 'lib/saucy/account.rb', line 48

def users_by_name
  users.by_name
end

#users_countObject



99
100
101
# File 'lib/saucy/account.rb', line 99

def users_count
  users.count
end