Sha256: 427cee3d581241275e456870ba0d9415392ab1066f11468c43389cb7dd53e98e

Contents?: true

Size: 599 Bytes

Versions: 18

Compression:

Stored size: 599 Bytes

Contents

# Detecting whether a class has a definition for a method or not
# changes between Ruby 1.8 and Ruby 1.9. We introduce the
# "flexmock_defined?" method on class objects to have a portable way
# to determine that.
#
# NOTE: responds_to? isn't appropriate. We don't care if the object
#       responds to the method or not. We want to know if the class
#       has a definition for the method. A subtle difference.
#
class Class

  # Does a class directly define a method named "method_name"?
  def flexmock_defined?(method_name)
    instance_methods.include?(method_name.flexmock_as_name)
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
flexmock-2.0.6 lib/flexmock/class_extensions.rb
flexmock-2.0.5 lib/flexmock/class_extensions.rb
flexmock-2.0.4 lib/flexmock/class_extensions.rb
flexmock-2.0.3 lib/flexmock/class_extensions.rb
flexmock-2.0.2 lib/flexmock/class_extensions.rb
flexmock-2.0.1 lib/flexmock/class_extensions.rb
flexmock-2.0.0 lib/flexmock/class_extensions.rb
flexmock-2.0.0.rc1 lib/flexmock/class_extensions.rb
flexmock-1.3.3 lib/flexmock/class_extensions.rb
flexmock-1.3.2 lib/flexmock/class_extensions.rb
flexmock-1.3.1 lib/flexmock/class_extensions.rb
flexmock-1.3.0 lib/flexmock/class_extensions.rb
flexmock-1.2.0 lib/flexmock/class_extensions.rb
flexmock-1.1.0 lib/flexmock/class_extensions.rb
flexmock-1.0.4 lib/flexmock/class_extensions.rb
flexmock-1.0.3 lib/flexmock/class_extensions.rb
flexmock-1.0.2 lib/flexmock/class_extensions.rb
flexmock-1.0.1 lib/flexmock/class_extensions.rb