Sha256: 949d10cd1517ce200adb3abccbd43d1ab8a51f9bc6f3fa80e0c5eaf5fe9176d5

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

module Lazier
  # Extensions for Hash objects.
  module Hash
    extend ::ActiveSupport::Concern

    # Makes sure that the keys of the hash are accessible in the desired way.
    #
    # @param access [Symbol|NilClass] The requested access for the keys. Can be `:strings`, `:symbols` or `:indifferent`. If `nil` the keys are not modified.
    def ensure_access(access)
      method = {strings: :stringify_keys, symbols: :symbolize_keys, indifferent: :with_indifferent_access}.fetch(access, nil)
      method ? send(method) : self
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lazier-3.3.10 lib/lazier/hash.rb
lazier-3.3.9 lib/lazier/hash.rb
lazier-3.3.8 lib/lazier/hash.rb
lazier-3.3.7 lib/lazier/hash.rb