Module: Moku::Keys

Defined in:
lib/core_extensions/hash/keys.rb

Overview

Behavior from ActiveSupport's hash/keys

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject


10
11
12
# File 'lib/core_extensions/hash/keys.rb', line 10

def stringify_keys
  deep_transform_keys(&:to_s)
end

#stringify_keys!Object


16
17
18
# File 'lib/core_extensions/hash/keys.rb', line 16

def stringify_keys!
  deep_transform_keys!(&:to_s)
end

#symbolize_keysObject


22
23
24
25
26
27
28
29
30
# File 'lib/core_extensions/hash/keys.rb', line 22

def symbolize_keys
  deep_transform_keys do |key|
    begin
      key.to_sym
    rescue StandardError
      key
    end
  end
end

#symbolize_keys!Object


34
35
36
37
38
39
40
41
42
# File 'lib/core_extensions/hash/keys.rb', line 34

def symbolize_keys!
  deep_transform_keys! do |key|
    begin
      key.to_sym
    rescue StandardError
      key
    end
  end
end