Sha256: c2ea15a8d3037837c821d7df3fcdc378530b58fe3968d3a881032ced69570161

Contents?: true

Size: 452 Bytes

Versions: 3

Compression:

Stored size: 452 Bytes

Contents

require 'rainbow/refinement'

module Squib::WarnUnexpectedParams
  using Rainbow # we can colorize strings now!

  def warn_if_unexpected(opts, uplevel: 5)
    accepted_params = self.class.accepted_params
    unexpected = opts.keys - accepted_params
    unexpected.each do |key|
      warn "Unexpected parameter '#{key.to_s.yellow}:' to #{dsl_method.to_s.cyan}(). Accepted parameters: #{accepted_params}",
           uplevel: uplevel
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
squib-0.19.0 lib/squib/errors_warnings/warn_unexpected_params.rb
squib-0.19.0b lib/squib/errors_warnings/warn_unexpected_params.rb
squib-0.19.0a lib/squib/errors_warnings/warn_unexpected_params.rb