Class: ESP::User

Inherits:
Resource show all
Defined in:
lib/esp/resources/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Dirty

#changed_attributes, #original_attributes, #original_attributes=

Methods included from LoadWithOriginalAttributes

#load

Class Method Details

.allActiveResource::PaginatedCollection<ESP::User>

Return a paginated User list



# File 'lib/esp/resources/user.rb', line 56


.create(attributes = {}) ⇒ ESP::User

Create a User. call-seq -> super.create(attributes={})

Examples:

user = ESP::User.create(first_name: 'John', last_name: 'Doe', email: "[email protected]")


# File 'lib/esp/resources/user.rb', line 61


.find(id, options = {}) ⇒ ESP::User

Find a User by id

call-seq -> super.find(id, options = {})



# File 'lib/esp/resources/user.rb', line 40


.where(clauses = {}) ⇒ ActiveResource::PaginatedCollection<ESP::User>

Return a paginated User list filtered by search parameters

call-seq -> super.where(clauses = {})



# File 'lib/esp/resources/user.rb', line 29


Instance Method Details

#destroyself

Delete a User.



# File 'lib/esp/resources/user.rb', line 85


#organizationESP::Organization

The organization this user belongs to.



6
# File 'lib/esp/resources/user.rb', line 6

belongs_to :organization, class_name: 'ESP::Organization'

#roleESP::Role

The role assigned to this user.



11
# File 'lib/esp/resources/user.rb', line 11

belongs_to :role, class_name: 'ESP::Role'

#saveBoolean

Create and update a User.

Valid Attributes

See API documentation for valid arguments

Examples:

user = ESP::User.new(first_name: 'John', last_name: 'Doe', email: "[email protected]")
user.save


# File 'lib/esp/resources/user.rb', line 73


#sub_organizationsActiveResource::PaginatedCollection<ESP::SubOrganization>

The collection of sub organizations that belong to the user.



16
17
18
19
# File 'lib/esp/resources/user.rb', line 16

def sub_organizations
  return attributes['sub_organizations'] if attributes['sub_organizations'].present?
  SubOrganization.where(id_in: sub_organization_ids)
end

#teamsActiveResource::PaginatedCollection<ESP::Team>

The collection of teams that belong to the user.



24
25
26
27
# File 'lib/esp/resources/user.rb', line 24

def teams
  return attributes['teams'] if attributes['teams'].present?
  Team.where(id_in: team_ids)
end