Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/kube/monkey_patches.rb

Overview

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/kube/monkey_patches.rb', line 3

def method_missing(name, *args)
  key = name.to_s

  if key.end_with("=")
    self[key.chomp("=").to_sym] = args.first

  elsif key?[name.to_sym]
    self[name.to_sym]

  else
    self[name.to_sym] = {}
  end
end

Instance Method Details

#respond_to_missing(name, _priv = false) ⇒ Object



17
18
19
# File 'lib/kube/monkey_patches.rb', line 17

def respond_to_missing(name, _priv = false)
  name.to_s.ends_with?("=") || key?(name.to_sym)
end