Sha256: 0d97bbd07debd37929b3374bbbab7edd008cff8a050e25a6323536163a0482c5

Contents?: true

Size: 631 Bytes

Versions: 1

Compression:

Stored size: 631 Bytes

Contents

module Rlyeh
  class Environment < ::Hash
    def respond_to?(method_id, include_private = false)
      super || respond_to_missing?(method_id, include_private)
    end

    def respond_to_missing?(method_name, include_private)
      method_name = method_id.to_s
      return true if method_name =~ /^(.+)=$/
      return true if self.key? method_name
      super
    end

    def method_missing(method_id, *args, &block)
      method_name = method_id.to_s
      return self[$1] = args.first if method_name =~ /^(.+)=$/
      return self[method_name] if self.key? method_name
      super method_id, *args, &block
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rlyeh-0.0.2 lib/rlyeh/environment.rb