Module: Simple::Service::Action::IndifferentHashEx

Defined in:
lib/simple/service/action.rb

Class Method Summary collapse

Class Method Details

.fetch(hsh, name) ⇒ Object



93
94
95
96
97
98
99
100
101
# File 'lib/simple/service/action.rb', line 93

def self.fetch(hsh, name)
  missing_key!(name) unless hsh

  hsh.fetch(name.to_sym) do
    hsh.fetch(name.to_s) do
      missing_key!(name)
    end
  end
end

.key?(hsh, name) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
106
107
# File 'lib/simple/service/action.rb', line 103

def self.key?(hsh, name)
  return false unless hsh

  hsh.key?(name.to_sym) || hsh.key?(name.to_s)
end

.missing_key!(name) ⇒ Object

Raises:



109
110
111
# File 'lib/simple/service/action.rb', line 109

def self.missing_key!(name)
  raise ArgumentError, "Missing argument in arguments hash: #{name}"
end