class Listen::Options

Public Class Methods

new(opts, defaults) click to toggle source
# File lib/listen/options.rb, line 5
def initialize(opts, defaults)
  @options = {}
  given_options = opts.dup
  defaults.each_key do |key|
    @options[key] = given_options.delete(key) || defaults[key]
  end

  given_options.empty? or raise ArgumentError, "Unknown options: #{given_options.inspect}"
end

Public Instance Methods

method_missing(name, *_) click to toggle source
# File lib/listen/options.rb, line 20
def method_missing(name, *_)
  respond_to_missing?(name) or raise NameError, "Bad option: #{name.inspect} (valid:#{@options.keys.inspect})"
  @options[name]
end
respond_to_missing?(name, *_) click to toggle source

rubocop:disable Lint/MissingSuper

# File lib/listen/options.rb, line 16
def respond_to_missing?(name, *_)
  @options.has_key?(name)
end