Sha256: 4cc15babc512021f403f2ce128a71008ca2ca96abe5ad500401ea95b4dd49a36

Contents?: true

Size: 436 Bytes

Versions: 1

Compression:

Stored size: 436 Bytes

Contents

require "surrounded/version"

module Surrounded
  private

  def method_missing(meth, *args, &block)
    context.role?(meth){} || super
  end

  def respond_to_missing?(meth, include_private=false)
    !!context.role?(meth){} || super
  end

  def context
    Thread.current[:context] ||= []
    Thread.current[:context].first || NullContext.new
  end

  class NullContext < BasicObject
    def role?(*args)
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
surrounded-0.1.0 lib/surrounded.rb