Class: Bluplate::User
- Inherits:
-
Object
- Object
- Bluplate::User
- Includes:
- Persist::Base
- Defined in:
- lib/bluplate/user.rb
Instance Attribute Summary collapse
-
#contacts ⇒ Object
Returns the value of attribute contacts.
-
#email ⇒ Object
Returns the value of attribute email.
-
#inbox ⇒ Object
Returns the value of attribute inbox.
-
#workstream ⇒ Object
Returns the value of attribute workstream.
Class Method Summary collapse
Instance Method Summary collapse
- #add_contacts(contacts) ⇒ Object
-
#initialize(opts) ⇒ User
constructor
A new instance of User.
- #to_hash ⇒ Object
Methods included from Persist::Base
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
#contacts ⇒ Object
Returns the value of attribute contacts.
8 9 10 |
# File 'lib/bluplate/user.rb', line 8 def contacts @contacts end |
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'lib/bluplate/user.rb', line 8 def email @email end |
#inbox ⇒ Object
Returns the value of attribute inbox.
8 9 10 |
# File 'lib/bluplate/user.rb', line 8 def inbox @inbox end |
#workstream ⇒ Object
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_hash ⇒ Object
18 19 20 |
# File 'lib/bluplate/user.rb', line 18 def to_hash {:email => @email, :inbox => @inbox, :workstream => @workstream, :contacts => @contacts } end |