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: {})


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

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

Instance Attribute Details

#argumentsHash (readonly)

Returns safe configuration.

Returns:

  • (Hash)

    safe configuration



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

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:



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

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)


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

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)


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

def unlock(value)
  raise NotImplementedError
end