Module: Micro::Attributes::AttributesUtils

Defined in:
lib/micro/attributes/attributes_utils.rb

Constant Summary collapse

ARGUMENT_ERROR_MSG =
'argument must be a Hash'

Class Method Summary collapse

Class Method Details

.hash_argument!(arg) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/micro/attributes/attributes_utils.rb', line 8

def self.hash_argument!(arg)
  return arg if arg.is_a?(Hash)

  raise ArgumentError, ARGUMENT_ERROR_MSG
end

.stringify_hash_keys!(arg) ⇒ Object



14
15
16
17
18
# File 'lib/micro/attributes/attributes_utils.rb', line 14

def self.stringify_hash_keys!(arg)
  hash_argument!(arg).each_with_object({}) do |(key, val), memo|
    memo[key.to_s] = val
  end
end