Class: Moodle::Api::TokenGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/moodle/api/token_generator.rb

Overview

Generates tokens using username, password and service Used for accessing Moodle API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ TokenGenerator

Returns a new instance of TokenGenerator.



8
9
10
# File 'lib/moodle/api/token_generator.rb', line 8

def initialize(configuration)
  @configuration = configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



6
7
8
# File 'lib/moodle/api/token_generator.rb', line 6

def configuration
  @configuration
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
# File 'lib/moodle/api/token_generator.rb', line 12

def call
  if raise_token_exception?
    fail ArgumentError,
         'Username and password are required to generate a token'
  end

  generate_token
end