Class: PivotalShell::Cache::User

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal_shell/cache/user.rb

Constant Summary collapse

ATTRIBUTES =
%w(name id initials email)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source = {}) ⇒ User

Returns a new instance of User.



9
10
11
12
13
14
15
# File 'lib/pivotal_shell/cache/user.rb', line 9

def initialize(source={})
  if source.is_a? PivotalTracker::Membership
    raise 'TODO'
  elsif source.is_a? Hash
    create_from_hash(source)
  end
end

Class Method Details

.find(id) ⇒ Object



21
22
23
24
# File 'lib/pivotal_shell/cache/user.rb', line 21

def self.find(id)
  hash = PivotalShell::Configuration.cache.db.execute("SELECT * FROM users WHERE id=? OR initials=? OR name=? OR email=?", id, id, id, id).first
  hash && new(hash)
end

Instance Method Details

#to_sObject



17
18
19
# File 'lib/pivotal_shell/cache/user.rb', line 17

def to_s
  name
end