class TimeDoctor::Config

Public Class Methods

[](key) click to toggle source
# File lib/timedoctor/config.rb, line 31
def [](key)
  config[key]
end
[]=(key, value) click to toggle source
# File lib/timedoctor/config.rb, line 35
def []=(key, value)
  config[key] = value
end
config() click to toggle source
# File lib/timedoctor/config.rb, line 27
def config
  @config || configure
end
configure(options = {}, &blk) click to toggle source
# File lib/timedoctor/config.rb, line 6
def configure(options = {}, &blk)
  @config = OpenStruct.new(options)

  config[:on_token_authorize] ||= lambda do |_data, _conf|
  end

  config[:on_token_authorize_error] ||= lambda do |data, _conf|
    raise UnauthorizedError, data
  end

  config[:on_token_refresh] ||= lambda do |_data, _conf|
  end

  config[:on_token_refresh_error] ||= lambda do |data, _conf|
    raise UnauthorizedError, data
  end

  instance_exec(config, &blk) if block_given?
  config
end
inspect() click to toggle source
# File lib/timedoctor/config.rb, line 39
def inspect
  config.to_h
end
new(options) click to toggle source
# File lib/timedoctor/config.rb, line 44
def initialize(options)
  @config = OpenStruct.new(options)
end

Public Instance Methods

[](key) click to toggle source
# File lib/timedoctor/config.rb, line 52
def [](key)
  config[key] || Config[key]
end
[]=(key, value) click to toggle source
# File lib/timedoctor/config.rb, line 56
def []=(key, value)
  config[key] = value
end
config() click to toggle source
# File lib/timedoctor/config.rb, line 48
def config
  @config ||= OpenStruct.new
end
inspect() click to toggle source
# File lib/timedoctor/config.rb, line 60
def inspect
  {
    local: @config.to_h,
    global: Config.inspect
  }
end