Class: SimplyAuth::UserPool

Inherits:
Model
  • Object
show all
Defined in:
app/models/simply_auth/user_pool.rb

Instance Attribute Summary collapse

Attributes inherited from Model

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#attributes=, collection_path, #collection_path, create, #data, #data=, find, #initialize, #instance_path, owner_class, owner_class_name, #owner_id, path_component, #persisted=, #persisted?, #save

Constructor Details

This class inherits a constructor from SimplyAuth::Model

Instance Attribute Details

#application_idObject

Returns the value of attribute application_id.



4
5
6
# File 'app/models/simply_auth/user_pool.rb', line 4

def application_id
  @application_id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'app/models/simply_auth/user_pool.rb', line 4

def name
  @name
end

Class Method Details

.allObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/simply_auth/user_pool.rb', line 17

def self.all
  response = RestClient.get(
    "https://api.simplyauth.com#{collection_path}",
    accept: :json
  )
  body = JSON.parse(response.body)[model_name.element.pluralize.camelize(:lower)]
  body.map do |data|
    data = data.deep_transform_keys { |key| key.to_s.underscore }
    new(data)
  end
end

.instance_path(ids = []) ⇒ Object



9
10
11
12
13
14
15
# File 'app/models/simply_auth/user_pool.rb', line 9

def self.instance_path(ids = [])
  if ids.empty?
    super([SimplyAuth::Config.user_pool_id])
  else
    super(ids)
  end
end

Instance Method Details

#attributesObject



5
6
7
# File 'app/models/simply_auth/user_pool.rb', line 5

def attributes
  super.merge(name: name, application_id: application_id)
end

#usersObject



29
30
31
# File 'app/models/simply_auth/user_pool.rb', line 29

def users
  @users ||= User.all(id)
end