Sha256: 77237f819f6d8fe59bb9bcd8d261d3e5769c6f4b12aff81d3f0496e105b5e665

Contents?: true

Size: 676 Bytes

Versions: 5

Compression:

Stored size: 676 Bytes

Contents

# frozen_string_literal: true
require 'hashie/mash'

module  Chamber
module  Filters
class   TranslateSecureKeysFilter
  SECURE_KEY_TOKEN = /\A_secure_/

  def initialize(options = {})
    self.data = options.fetch(:data).dup
  end

  def self.execute(options = {})
    new(options).__send__(:execute)
  end

  protected

  attr_accessor :data

  def execute(raw_data = data)
    settings = Hashie::Mash.new

    raw_data.each_pair do |key, value|
      value = execute(value) if value.respond_to? :each_pair
      key   = key.to_s
      key   = key.sub(SECURE_KEY_TOKEN, '') if key.match(SECURE_KEY_TOKEN)

      settings[key] = value
    end

    settings
  end
end
end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chamber-2.10.2 lib/chamber/filters/translate_secure_keys_filter.rb
chamber-2.10.1 lib/chamber/filters/translate_secure_keys_filter.rb
chamber-2.10.0 lib/chamber/filters/translate_secure_keys_filter.rb
chamber-2.9.1 lib/chamber/filters/translate_secure_keys_filter.rb
chamber-2.9.0 lib/chamber/filters/translate_secure_keys_filter.rb