Module: Accounts::IsAUser
- Defined in:
- lib/accounts/is_a_user.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#csv_options(override_options = {}) ⇒ Hash
Returns CSV options associated with this user from PADMA ACCOUNTS.
-
#enabled_accounts ⇒ Array <PadmaAccount>
Returns enabled accounts associated with this user from PADMA ACCOUNTS.
- #encoding ⇒ Object
-
#locale ⇒ String
Returns locale for this user retrieving it from PADMA ACCOUNTS.
- #padma(cache = true) ⇒ PadmaUser
-
#padma_enabled? ⇒ TrueClass
Returns true if this user has enabled padma accounts.
- #separator ⇒ Object
Class Method Details
.included(base) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/accounts/is_a_user.rb', line 10 def self.included(base) base.send(:validate, :has_access_to_current_account) base.send(:include, Accounts::BelongsToUser) base.send(:include, Accounts::BelongsToAccount) base.send(:include, Gravtastic) base.send(:gravtastic) begin unless base.new.respond_to?(:email) base.send(:delegate, :email, to: :padma_user, allow_nil: true) end rescue # this is run when booting app, is base model needs DB persistance and this has not yet been provided # app will never boot or be able to run migrations. so we rescue exception here. end base.send(:delegate, :verbose_help?, to: :padma_user, allow_nil: true) end |
Instance Method Details
#csv_options(override_options = {}) ⇒ Hash
Returns CSV options associated with this user from PADMA ACCOUNTS
59 60 61 62 63 64 65 |
# File 'lib/accounts/is_a_user.rb', line 59 def (={}) = CSV_DEFAULTS.clone [:col_sep] = self.padma.try :separator [:encoding] = self.padma.try :encoding return .merge(.to_hash.symbolize_keys!) end |
#enabled_accounts ⇒ Array <PadmaAccount>
Returns enabled accounts associated with this user from PADMA ACCOUNTS
52 53 54 |
# File 'lib/accounts/is_a_user.rb', line 52 def enabled_accounts self.padma.try(:enabled_accounts) end |
#encoding ⇒ Object
67 68 69 |
# File 'lib/accounts/is_a_user.rb', line 67 def encoding @encoding ||= self.padma.encoding end |
#locale ⇒ String
Returns locale for this user retrieving it from PADMA ACCOUNTS
45 46 47 |
# File 'lib/accounts/is_a_user.rb', line 45 def locale self.padma.try :locale end |
#padma(cache = true) ⇒ PadmaUser
31 32 33 |
# File 'lib/accounts/is_a_user.rb', line 31 def padma(cache=true) self.user(force_service_call: !cache) end |
#padma_enabled? ⇒ TrueClass
Returns true if this user has enabled padma accounts
38 39 40 41 |
# File 'lib/accounts/is_a_user.rb', line 38 def padma_enabled? ea = self.enabled_accounts !(ea.nil? || ea.empty?) end |
#separator ⇒ Object
71 72 73 |
# File 'lib/accounts/is_a_user.rb', line 71 def separator @separator ||= self.padma.separator end |