Class: Bluplate::User

Inherits:
Object
  • Object
show all
Includes:
Persist::Base
Defined in:
lib/bluplate/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Persist::Base

included, #save

Constructor Details

#initialize(opts) ⇒ User

Returns a new instance of User.



10
11
12
13
14
15
16
# File 'lib/bluplate/user.rb', line 10

def initialize(opts)

  @email = opts[:email]
  @inbox = opts[:inbox] || {}
  @contacts = opts[:contacts] || {}
  @workstream = opts[:workstream] || {}
end

Instance Attribute Details

#contactsObject

Returns the value of attribute contacts.



8
9
10
# File 'lib/bluplate/user.rb', line 8

def contacts
  @contacts
end

#emailObject

Returns the value of attribute email.



8
9
10
# File 'lib/bluplate/user.rb', line 8

def email
  @email
end

#inboxObject

Returns the value of attribute inbox.



8
9
10
# File 'lib/bluplate/user.rb', line 8

def inbox
  @inbox
end

#workstreamObject

Returns the value of attribute workstream.



8
9
10
# File 'lib/bluplate/user.rb', line 8

def workstream
  @workstream
end

Class Method Details

.create(opts = {}) ⇒ Object



32
33
34
35
36
# File 'lib/bluplate/user.rb', line 32

def self.create(opts={})
  u = self.new(opts)
  u.save
  u
end

.find_by_email(email) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/bluplate/user.rb', line 22

def self.find_by_email(email)
  if user_h = db.collection("users").find_one({"email" => email}) 
    user_hash =  user_h.each{ |doc| doc.inspect }
  else
    user_hash = nil
  end
  inbox = user_hash ? user_hash["inbox"] : {}
  User.new(:email => email, :inbox => inbox)
end

Instance Method Details

#add_contacts(contacts) ⇒ Object



38
39
40
# File 'lib/bluplate/user.rb', line 38

def add_contacts(contacts)

end

#to_hashObject



18
19
20
# File 'lib/bluplate/user.rb', line 18

def to_hash
  {:email => @email, :inbox => @inbox, :workstream => @workstream, :contacts => @contacts }
end