Sha256: 3b873d3afa7bca5b85a97a1e2c57296dcce1fb53f0594171e62c0657c928ec48

Contents?: true

Size: 1.53 KB

Versions: 11

Compression:

Stored size: 1.53 KB

Contents

# = Main as Module
#
# Main, ie. the top-level object, is not fully in-sync with
# Module. So, certain methods like #define_method do not work.
# This library fixes this.
#
# Techinally it is this authors opinion that the top-level object
# most likely be better-off as a self-extended module, and
# method defined in it do not automatically get added to the
# Object class.
#
# == Copying
#
# Copyright (c) 2006 Thomas Sawyer
#
# Ruby License
#
# This module is free software. You may use, modify, and/or redistribute this
# software under the same terms as Ruby.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
#
# == Authors
#
# * Thomas Sawyer

public

(Module.public_instance_methods - public_methods).each do |m|
  next if m == "initialize"
  next if m =~ /^\W+$/
  eval <<-END
    def self.#{m}( *args, &block )
      Object.class_eval do
        #{m}( *args, &block )
      end
    end
  END
end

private

(Module.private_instance_methods - private_methods).each do |m|
  next if m == "initialize"
  next if m =~ /^\W+$/
  eval <<-END
    def self.#{m}( *args, &block )
      Object.class_eval do
        #{m}( *args, &block )
      end
    end
  END
end

protected

(Module.protected_instance_methods - protected_methods).each do |m|
  next if m == "initialize"
  next if m =~ /^\W+$/
  eval <<-END
    def self.#{m}( *args, &block )
      Object.class_eval do
        #{m}( *args, &block )
      end
    end
  END
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
facets-2.6.0 lib/more/facets/main.rb
facets-2.4.0 lib/facets/main.rb
facets-2.4.1 lib/facets/main.rb
facets-2.4.2 lib/more/facets/main.rb
facets-2.4.3 lib/more/facets/main.rb
facets-2.4.4 lib/more/facets/main.rb
facets-2.5.0 lib/more/facets/main.rb
facets-2.5.1 lib/more/facets/main.rb
facets-2.4.5 lib/more/facets/main.rb
facets-2.5.2 lib/more/facets/main.rb
mack-facets-0.8.2 lib/gems/facets-2.4.5/lib/more/facets/main.rb