Class: Locomotive::Account
- Inherits:
-
Object
- Object
- Locomotive::Account
- Includes:
- Concerns::Account::ApiKey, Mongoid::Document
- Defined in:
- app/models/locomotive/account.rb
Class Method Summary collapse
-
.find_by_email(email) ⇒ Object
Find the first account matching the email parameter.
Instance Method Summary collapse
-
#api_token ⇒ Object
aliases ##.
-
#created_sites ⇒ Object
associations ##.
- #devise_mailer ⇒ Object
-
#local_admin? ⇒ Boolean
Tell if the account has admin privileges for one (at least) of his/her sites.
-
#name ⇒ Object
validations ##.
-
#ordered ⇒ Object
scopes ##.
-
#remember_created_at ⇒ Object
devise fields (need to be declared since 2.x) ##.
-
#sites ⇒ Object
methods ##.
Methods included from Concerns::Account::ApiKey
#regenerate_api_key, #regenerate_api_key!
Class Method Details
.find_by_email(email) ⇒ Object
Find the first account matching the email parameter
72 73 74 |
# File 'app/models/locomotive/account.rb', line 72 def self.find_by_email(email) where(email: email).first end |
Instance Method Details
#api_token ⇒ Object
aliases ##
49 |
# File 'app/models/locomotive/account.rb', line 49 alias_attribute :api_token, :api_key |
#created_sites ⇒ Object
associations ##
36 |
# File 'app/models/locomotive/account.rb', line 36 has_many :created_sites, class_name: 'Locomotive::Site', validate: false, autosave: false |
#devise_mailer ⇒ Object
76 77 78 |
# File 'app/models/locomotive/account.rb', line 76 def devise_mailer Locomotive::DeviseMailer end |
#local_admin? ⇒ Boolean
Tell if the account has admin privileges for one (at least) of his/her sites.
62 63 64 |
# File 'app/models/locomotive/account.rb', line 62 def local_admin? Site.where(memberships: { '$elemMatch' => { account_id: self._id, role: :admin } }).count > 0 end |
#name ⇒ Object
validations ##
26 |
# File 'app/models/locomotive/account.rb', line 26 field :name |
#ordered ⇒ Object
scopes ##
42 |
# File 'app/models/locomotive/account.rb', line 42 scope :ordered, -> { order_by(name: :asc) } |
#remember_created_at ⇒ Object
devise fields (need to be declared since 2.x) ##
10 |
# File 'app/models/locomotive/account.rb', line 10 field :remember_created_at, type: Time |
#sites ⇒ Object
methods ##
53 54 55 |
# File 'app/models/locomotive/account.rb', line 53 def sites @sites ||= Site.where('memberships.account_id' => self._id) end |