Sha256: 6f9d4c231e3a0f231a2a4db9190603d781cc490b65e1d8e5ee75e39f3e045f7b

Contents?: true

Size: 523 Bytes

Versions: 1

Compression:

Stored size: 523 Bytes

Contents

require "robustly"
require "shrug/version"

module Shrug
  WHITELIST = %w(to_ary constantize to_str)

  def method_missing(method, *args, &block)
    return if WHITELIST.include?(method.to_s)

    STDERR.puts("¯\\_(ツ)_/¯ (`#{method.to_s}' undefined)")

    safely default: self do
      raise NoMethodError.new("undefined method `#{method}' for nil:NilClass (¯\\_(ツ)_/¯)")
    end
  end

  def respond_to_missing?(method, *args, &block)
    !WHITELIST.include?(method.to_s)
  end
end

NilClass.send :include, Shrug

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shrug-0.0.4 lib/shrug.rb