class NexaasID::Resources::Base

Default root for all resource classes.

Attributes

api[R]
configuration[R]

Public Class Methods

new(api, config) click to toggle source

Creates an instance of this class.

@param [api] api An instance of OAuth2::AccessToken

# File lib/nexaas_id/resources/base.rb, line 8
def initialize(api, config)
  @api = api
  @configuration = config
end

Protected Instance Methods

base_klass() click to toggle source
# File lib/nexaas_id/resources/base.rb, line 30
def base_klass
  @base_klass ||= self.class.name.split("::").last
end
entity_klass() click to toggle source
# File lib/nexaas_id/resources/base.rb, line 34
def entity_klass
  @entity_klass ||= NexaasID::Entities.const_get(base_klass.to_sym)
end
respond_with_entity(response, naked_klass = entity_klass) click to toggle source

Builds an entity from the OAuth2 response.

@param [OAuth2::Response] response The response from any OAuth2::AccessToken method @param [NexaasID::Entities::Base] naked_klass The class which the response will be

deserialized into (must be a subtype of NexaasID::Entities::Base).
Optional if the entity name is the same as the resource name.

@return [NexaasID::Entities::Base] an instance of naked_class

# File lib/nexaas_id/resources/base.rb, line 25
def respond_with_entity(response, naked_klass = entity_klass)
  # response.parsed is a Hash
  naked_klass.new(response.parsed)
end