Module: SfnParameters::Utils

Included in:
Sfn::Callback::ParametersInfrastructure, Sfn::Command::Parameters
Defined in:
lib/sfn-parameters/utils.rb

Overview

Common helper methods

Instance Method Summary collapse

Instance Method Details

#lock_content(content) ⇒ Hash

Lock the given content

Parameters:

  • content (Hash)

    content to lock

Returns:

  • (Hash)

    locked content



11
12
13
14
15
16
17
18
# File 'lib/sfn-parameters/utils.rb', line 11

def lock_content(content)
  content = content.to_smash
  content.merge!(:sfn_lock_enabled => true)
  safe = SfnParameters::Safe.build(
    config.fetch(:sfn_parameters, :safe, Smash.new)
  )
  safe.lock(dump_json(content))
end

#unlock_content(content) ⇒ Hash

Unlock given content

Parameters:

  • content (Hash)

    content to unlock

Returns:

  • (Hash)

    unlocked content



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sfn-parameters/utils.rb', line 24

def unlock_content(content)
  content = content.to_smash
  if content[:sfn_parameters_lock]
    safe = SfnParameters::Safe.build(
      config.fetch(:sfn_parameters, :safe, Smash.new)
    )
    load_json(safe.unlock(content)).to_smash.merge(:sfn_lock_enabled => true)
  else
    content
  end
end