Class: Fernet::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/fernet/configuration.rb

Overview

Public: singleton class used to globally set various configuration defaults

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#enforce_ttlObject

Public: Returns whether to enforce a message TTL (true or false)


9
10
11
# File 'lib/fernet/configuration.rb', line 9

def enforce_ttl
  @enforce_ttl
end

#ttlObject

Public: Returns how many seconds messages are considered valid for


12
13
14
# File 'lib/fernet/configuration.rb', line 12

def ttl
  @ttl
end

Class Method Details

.method_missing(method) ⇒ Object


37
38
39
40
41
42
43
# File 'lib/fernet/configuration.rb', line 37

def method_missing(method)
  if self.instance.respond_to?(method)
    self.instance.send(method)
  else
    super
  end
end

.respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)

45
46
47
# File 'lib/fernet/configuration.rb', line 45

def respond_to?(method)
  self.instance.respond_to?(method) || super
end

.run {|self.instance| ... } ⇒ Object

Public: used to configure fernet, typically invoked in an initialization

routine

Sets the following values:

  • enforce_ttl: true

  • ttl: 60

Yields the singleton configuration object, where above defaults can be

overridden

Examples

Fernet::Configuration.run do |config|
  config.enforce_ttl = false
end

Yields:

  • (self.instance)

30
31
32
33
34
# File 'lib/fernet/configuration.rb', line 30

def self.run
  self.instance.enforce_ttl = true
  self.instance.ttl         = 60
  yield self.instance if block_given?
end