Sha256: 4b099c17564a30a14d3fc5c8d4acd51af743cd856863f4b17566bfcc0cfb77ea

Contents?: true

Size: 411 Bytes

Versions: 1

Compression:

Stored size: 411 Bytes

Contents

require 'nerv/version'

class Nerv
  DEFAULT_SEPARATOR = '_'.freeze

  class << self
    def prefix(keys_prefix, separator = DEFAULT_SEPARATOR)
      regexp = /^#{keys_prefix}#{separator}/

      pairs = ENV.map { |k, v| [k.gsub(regexp, ''), v] if k =~ regexp }
                 .compact
                 .flatten

      Hash[*pairs]
    end

    def [](keys_prefix)
      prefix(keys_prefix)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nerv-0.0.1 lib/nerv.rb