Sha256: da985f78d3e8cb32186b4f186b6ae0147582909e8bdfbe1112a409eec97e11d2

Contents?: true

Size: 605 Bytes

Versions: 10

Compression:

Stored size: 605 Bytes

Contents

# frozen_string_literal: true

module Epuber
  class HashBinding
    # @param [Hash] vars
    #
    def initialize(vars = {})
      @vars = vars
    end

    # @return [Boolean]
    #
    def respond_to_missing?(name, _include_private = false)
      @vars.key?(name) || super
    end

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

      @vars[name]
    end

    # rubocop:disable Naming/AccessorMethodName

    def get_binding
      binding
    end

    # rubocop:enable Naming/AccessorMethodName
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
epuber-0.11.1 lib/epuber/vendor/hash_binding.rb
epuber-0.11.0 lib/epuber/vendor/hash_binding.rb
epuber-0.10.3 lib/epuber/vendor/hash_binding.rb
epuber-0.10.2 lib/epuber/vendor/hash_binding.rb
epuber-0.10.1 lib/epuber/vendor/hash_binding.rb
epuber-0.9.3 lib/epuber/vendor/hash_binding.rb
epuber-0.9.2 lib/epuber/vendor/hash_binding.rb
epuber-0.9.1 lib/epuber/vendor/hash_binding.rb
epuber-0.9.0 lib/epuber/vendor/hash_binding.rb
epuber-0.8.0 lib/epuber/vendor/hash_binding.rb