Class: Garage::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/garage/config.rb

Defined Under Namespace

Classes: Builder

Constant Summary collapse

DEFAULT_RESCUE_ERROR =
true

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



18
19
20
21
# File 'lib/garage/config.rb', line 18

def initialize
  @cache_acceess_token_validation = false
  @ttl_for_access_token_cache = 5.minutes
end

Instance Attribute Details

#auth_server_hostObject

Returns the value of attribute auth_server_host.



16
17
18
# File 'lib/garage/config.rb', line 16

def auth_server_host
  @auth_server_host
end

#auth_server_timeoutObject

Returns the value of attribute auth_server_timeout.



16
17
18
# File 'lib/garage/config.rb', line 16

def auth_server_timeout
  @auth_server_timeout
end

#auth_server_urlObject

Returns the value of attribute auth_server_url.



16
17
18
# File 'lib/garage/config.rb', line 16

def auth_server_url
  @auth_server_url
end

#cache_acceess_token_validation=(value) ⇒ Object (writeonly)

Sets the attribute cache_acceess_token_validation

Parameters:

  • value

    the value to set the attribute cache_acceess_token_validation to.



15
16
17
# File 'lib/garage/config.rb', line 15

def cache_acceess_token_validation=(value)
  @cache_acceess_token_validation = value
end

#cast_resourceObject



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/garage/config.rb', line 51

def cast_resource
  @cast_resource ||= proc { |resource, options|
    options ||= {}
    to_resource_args = [options[:to_resource_options]].compact
    if resource.respond_to?(:map) && resource.respond_to?(:to_a)
      resource.map { |r| r.to_resource(*to_resource_args) }
    else
      resource.to_resource(*to_resource_args)
    end
  }
end

#docsObject



47
48
49
# File 'lib/garage/config.rb', line 47

def docs
  @docs ||= Docs::Config.new
end

#rescue_errortrue, false

Set false if you want to rescue errors by yourself

Examples:

Garage.configuration.rescue_error = false

Returns:

  • (true, false)

    A flag to rescue Garage::HTTPError in ControllerHelper (default: true)



27
28
29
# File 'lib/garage/config.rb', line 27

def rescue_error
  instance_variable_defined?(:@rescue_error) ? @rescue_error : DEFAULT_RESCUE_ERROR
end

#strategyModule

Set authentication strategy module which must satisfy Strategy interface.

Examples:

Garage.configuration.strategy = Garage::Strategy::AuthServer

Returns:

  • (Module)

    A auth strategy. default is NoAuthentication strategy.



35
36
37
# File 'lib/garage/config.rb', line 35

def strategy
  instance_variable_defined?(:@strategy) ? @strategy : Garage::Strategy::NoAuthentication
end

#tracerObject



43
44
45
# File 'lib/garage/config.rb', line 43

def tracer
  @tracer ||= Garage::Tracer::NullTracer
end

#ttl_for_access_token_cacheObject

Returns the value of attribute ttl_for_access_token_cache.



16
17
18
# File 'lib/garage/config.rb', line 16

def ttl_for_access_token_cache
  @ttl_for_access_token_cache
end

Instance Method Details

#cache_acceess_token_validation?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/garage/config.rb', line 63

def cache_acceess_token_validation?
  !!@cache_acceess_token_validation
end