Class: Module

Inherits:
Object show all
Defined in:
lib/gems/builder-2.1.2/lib/blankslate.rb,
lib/gems/abstract-1.0.0/lib/abstract.rb,
lib/gems/logging-0.9.4/lib/logging/utils.rb,
lib/gems/flexmock-0.8.3/lib/flexmock/deprecated_methods.rb

Overview

Also, modules included into Object need to be scanned and have their instance methods removed from blank slate. In theory, modules included into Kernel would have to be removed as well, but a “feature” of Ruby prevents late includes into modules from being exposed in the first place.

Direct Known Subclasses

Spec::Example::SharedExampleGroup

Instance Method Summary collapse

Instance Method Details

#abstract_method(args_str, *method_names) ⇒ Object

define abstract methods



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gems/abstract-1.0.0/lib/abstract.rb', line 41

def abstract_method args_str, *method_names
  method_names.each do |name|
    module_eval <<-END
      def #{name}(#{args_str})
        mesg = "class \#{self.class.name} must implement abstract method `#{self.name}##{name}()'."
        #mesg = "\#{self.class.name}##{name}() is not implemented."
        err = NotImplementedError.new mesg
        err.set_backtrace caller()
        raise err
      end
    END
  end
end

#append_features(mod) ⇒ Object



105
106
107
108
109
110
111
112
# File 'lib/gems/builder-2.1.2/lib/blankslate.rb', line 105

def append_features(mod)
  result = blankslate_original_append_features(mod)
  return result if mod != Object
  instance_methods.each do |name|
    BlankSlate.hide(name)
  end
  result
end

#blankslate_original_append_featuresObject



104
# File 'lib/gems/builder-2.1.2/lib/blankslate.rb', line 104

alias blankslate_original_append_features append_features

#flexmock_deprecate(*method_names) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gems/flexmock-0.8.3/lib/flexmock/deprecated_methods.rb', line 14

def flexmock_deprecate(*method_names)
  method_names.each do |method_name|
    eval_line = __LINE__ + 1
    module_eval %{
      def #{method_name}(*args)
        $stderr.puts "#{method_name} is deprecated, use flex#{method_name} instead"
        flex#{method_name}(*args)
      end
    }, __FILE__, eval_line
  end
end

#logger_nameObject

call-seq:

logger_name    #=> string

Returns a predictable logger name for the current module or class. If used within an anonymous class, the first non-anonymous class name will be used as the logger name. If used within a meta-class, the name of the actual class will be used as the logger name. If used within an anonymous module, the string ‘anonymous’ will be returned.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/gems/logging-0.9.4/lib/logging/utils.rb', line 83

def logger_name
  return name unless name.empty?

  # check if this is a metaclass (or eigenclass)
  if ancestors.include? Class
    inspect =~ %r/#<Class:([^#>]+)>/
    return $1
  end

  # see if we have a superclass
  if respond_to? :superclass
    return superclass.logger_name
  end

  # we are an anonymous module
  ::Logging.log_internal(-2) {
    'cannot return a predictable, unique name for anonymous modules'
  }
  return 'anonymous'
end