Module: LazyValue

Defined in:
lib/lazy_value.rb,
lib/lazy_value/engine.rb,
lib/lazy_value/railtie.rb,
lib/lazy_value/version.rb,
app/helpers/lazy_value/application_helper.rb,
app/controllers/lazy_value/application_controller.rb

Defined Under Namespace

Modules: ApplicationHelper Classes: ApplicationController, Engine, Railtie

Constant Summary collapse

VERSION =
"0.0.3"
@@key =
ENV["LAZY_VALUE_KEY"].presence || SecureRandom.hex(32)
@@salt =
ENV["LAZY_VALUE_SALT"].presence || SecureRandom.hex(8)

Class Method Summary collapse

Class Method Details

.cryptographyObject



16
17
18
19
20
# File 'lib/lazy_value.rb', line 16

def self.cryptography
  @cryptography ||= begin
    ActiveSupport::MessageEncryptor.new(derived_key)
  end
end

.derived_keyObject



22
23
24
# File 'lib/lazy_value.rb', line 22

def self.derived_key
  key_generator.generate_key(salt, 32)
end

.key_generatorObject



26
27
28
# File 'lib/lazy_value.rb', line 26

def self.key_generator
  ActiveSupport::KeyGenerator.new(key, iterations: 1000)
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (LazyValue)

    the object that the method was called on



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

def self.setup
  yield(self)
end