Class: SfnParameters::Safe

Inherits:
Object
  • Object
show all
Defined in:
lib/sfn-parameters/safe.rb,
lib/sfn-parameters/safe/ssl.rb

Overview

Safe storage

Direct Known Subclasses

Ssl

Defined Under Namespace

Classes: Ssl

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ self

Create a new safe

Parameters:

  • args (Hash) (defaults to: {})


15
16
17
# File 'lib/sfn-parameters/safe.rb', line 15

def initialize(args = {})
  @arguments = args.to_smash
end

Instance Attribute Details

#argumentsHash (readonly)

Returns safe configuration.

Returns:

  • (Hash)

    safe configuration



9
10
11
# File 'lib/sfn-parameters/safe.rb', line 9

def arguments
  @arguments
end

Class Method Details

.build(args = {}) ⇒ Safe

Build a new safe instance

Parameters:

  • args (Hash) (defaults to: {})

    arguments for safe instance

Options Hash (args):

  • :type (String)

    type of safe

Returns:



42
43
44
45
46
47
48
49
50
# File 'lib/sfn-parameters/safe.rb', line 42

def build(args = {})
  args = args.to_smash
  type = Bogo::Utility.camel(args.fetch(:type, "ssl"))
  if const_defined?(type)
    const_get(type).new(args)
  else
    raise ArgumentError.new "Unknown safe type provided `#{type}`."
  end
end

Instance Method Details

#lock(value) ⇒ Hash

Lock a given value for storage

Parameters:

  • value (String)

    value to lock

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/sfn-parameters/safe.rb', line 23

def lock(value)
  raise NotImplementedError
end

#unlock(value) ⇒ String

Unlock a given value for access

Parameters:

  • value (Hash)

    content to unlock

Returns:

  • (String)

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/sfn-parameters/safe.rb', line 31

def unlock(value)
  raise NotImplementedError
end