Class: Epuber::HashBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/epuber/vendor/hash_binding.rb

Instance Method Summary collapse

Constructor Details

#initialize(vars = {}) ⇒ HashBinding

Returns a new instance of HashBinding.

Parameters:

  • vars (Hash) (defaults to: {})


7
8
9
# File 'lib/epuber/vendor/hash_binding.rb', line 7

def initialize(vars = {})
  @vars = vars
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object

Parameters:

  • name (String)

Raises:

  • (NameError)


19
20
21
22
23
# File 'lib/epuber/vendor/hash_binding.rb', line 19

def method_missing(name)
  raise NameError, "Not found value for key #{name}" unless @vars.key?(name)

  @vars[name]
end

Instance Method Details

#get_bindingObject

rubocop:disable Naming/AccessorMethodName



27
28
29
# File 'lib/epuber/vendor/hash_binding.rb', line 27

def get_binding
  binding
end

#respond_to_missing?(name, _include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/epuber/vendor/hash_binding.rb', line 13

def respond_to_missing?(name, _include_private = false)
  @vars.key?(name) || super
end