Class: Trajectory::Users
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Trajectory::Users
- Defined in:
- lib/trajectory/domain/users.rb
Class Method Summary collapse
-
.from_json(json_attributes) ⇒ Object
Create a new collection of User from a JSON array of attributes from trajectory API.
Instance Method Summary collapse
-
#find_by_id(id) ⇒ User, false
Returns the the first user with the given id in the collection or false if no user can be found with the id.
-
#initialize(*users) ⇒ Users
constructor
Creates a new collection of User.
Constructor Details
#initialize(*users) ⇒ Users
Creates a new collection of Trajectory::User
8 9 10 |
# File 'lib/trajectory/domain/users.rb', line 8 def initialize(*users) super(users) end |
Class Method Details
.from_json(json_attributes) ⇒ Object
Create a new collection of Trajectory::User from a JSON array of attributes from trajectory API
15 16 17 18 19 |
# File 'lib/trajectory/domain/users.rb', line 15 def self.from_json(json_attributes) new(*json_attributes.map do |attributes| User.new(attributes.symbolize_keys!) end) end |
Instance Method Details
#find_by_id(id) ⇒ User, false
Returns the the first user with the given id in the collection or false if no user can be found with the id
26 27 28 |
# File 'lib/trajectory/domain/users.rb', line 26 def find_by_id(id) users.find { |user| user.id == id } || false end |