Class: PadmaUser

Inherits:
LogicalModel
  • Object
show all
Includes:
Gravtastic
Defined in:
app/models/padma_user.rb

Constant Summary collapse

TIMEOUT =

milisecons

5500
PER_PAGE =
9999

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cached_current_accountObject

Returns the value of attribute cached_current_account.



54
55
56
# File 'app/models/padma_user.rb', line 54

def 
  @cached_current_account
end

Class Method Details

.find_with_rails_cache(username, options = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'app/models/padma_user.rb', line 34

def self.find_with_rails_cache(username,options = {})
  pu = Rails.cache.read([username,"padma_user"])
  if pu.nil? || options[:refresh]
    pu = find(username)
    if pu
      Rails.cache.write([username,"padma_user"], pu, :expires_in => (options[:expires_in] || 5.minutes))  
    end
  end
  pu
end

Instance Method Details

#current_accountPadmaAccount

Returns:



46
47
48
49
50
51
52
53
# File 'app/models/padma_user.rb', line 46

def 
  unless 
    if self.
      self.= PadmaAccount.find_with_rails_cache(self.)
    end
  end
  
end

#enabled_accountsArray <PadmaAccount>

Returns me enabled accounts as Padma::Account objects

Returns:



66
67
68
69
# File 'app/models/padma_user.rb', line 66

def enabled_accounts
  return [] if self.accounts.nil?
  self.accounts.reject{|a|!a['enabled']}.map{|a|PadmaAccount.new(a)}
end

#json_rootObject

Attributes will be sent to server under this key. json_root => { … attributes }



77
78
79
# File 'app/models/padma_user.rb', line 77

def json_root
  :user
end

#padma_accountsArray <PadmaAccount>

Returns my accounts as Padma::Account objects

Returns:



59
60
61
62
# File 'app/models/padma_user.rb', line 59

def padma_accounts
  return nil if self.accounts.nil?
  self.accounts.map{|a|PadmaAccount.new(a)}
end

#verbose_help?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'app/models/padma_user.rb', line 71

def verbose_help?
  !!self.verbose_help
end