Class: Slurper::User
- Inherits:
-
Object
- Object
- Slurper::User
- Defined in:
- lib/slurper/user.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(attrs = {}) ⇒ User
constructor
A new instance of User.
- #name ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ User
Returns a new instance of User.
4 5 6 |
# File 'lib/slurper/user.rb', line 4 def initialize(attrs={}) self.attributes = (attrs || {}).symbolize_keys end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/slurper/user.rb', line 3 def attributes @attributes end |
Class Method Details
.collection ⇒ Object
8 9 10 11 12 |
# File 'lib/slurper/user.rb', line 8 def self.collection @collection ||= Slurper::Client.users.map do |attrs| Slurper::User.new(attrs['person']) end end |
.find_by_name(name) ⇒ Object
14 15 16 |
# File 'lib/slurper/user.rb', line 14 def self.find_by_name(name) collection.detect { |user| user.name == name } end |
Instance Method Details
#id ⇒ Object
19 |
# File 'lib/slurper/user.rb', line 19 def id; attributes[:id] end |
#name ⇒ Object
18 |
# File 'lib/slurper/user.rb', line 18 def name; attributes[:name] end |