Sha256: 9b411c69bb1e16db9b7fbcc0140ab0e98c02f7cb93ddd9b663dd322fb09ba0dd

Contents?: true

Size: 617 Bytes

Versions: 7

Compression:

Stored size: 617 Bytes

Contents

module InlineTemplates
  class BlankObject < BasicObject
    include ::Kernel

    def self.make_blank(*keep)
      old_verbose = $VERBOSE
      begin
        $VERBOSE = nil

        drop_methods [ :!, :!=, :==, :__id__, :__send__, :equal?, :instance_eval, :instance_exec ], keep
        drop_methods ::Kernel.instance_methods, keep
        drop_methods ::Kernel.private_instance_methods, keep

      ensure
        $VERBOSE = old_verbose
      end
    end

    def self.drop_methods(methods, keep)
      methods.each do |name|
        next if keep.include? name

        undef_method name
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
inline_templates-1.0.0 lib/inline_templates/blank_object.rb
inline_templates-0.0.6 lib/inline_templates/blank_object.rb
inline_templates-0.0.5 lib/inline_templates/blank_object.rb
inline_templates-0.0.4 lib/inline_templates/blank_object.rb
inline_templates-0.0.3 lib/inline_templates/blank_object.rb
inline_templates-0.0.2 lib/inline_templates/blank_object.rb
inline_templates-0.0.1 lib/inline_templates/blank_object.rb