Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/rucola/test_helper.rb,
lib/rucola/rucola_support/core_ext/ruby/object.rb
Class Method Summary collapse
-
.extended_class_methods ⇒ Object
Returns an array of all the class methods that were added by extending the class.
-
.metaclass ⇒ Object
Returns a class’s metaclass.
-
.original_class_methods ⇒ Object
Returns an array of all the class methods that were defined in only this class, so without class methods from any of it’s superclasses or from extending it.
-
.own_class_methods ⇒ Object
Returns an array of all the class methods that were defined in this class without the ones that were defined in it’s superclasses.
Instance Method Summary collapse
-
#ivar(name) ⇒ Object
A mocha helper to get at an instance variable without having to use instance_variable_get.
Class Method Details
.extended_class_methods ⇒ Object
Returns an array of all the class methods that were added by extending the class.
class FooBar; end
module Baz
def a_new_class_method; end
end
FooBar.extend(Baz)
FooBar.extended_class_methods # => ['a_new_class_method']
20 21 22 |
# File 'lib/rucola/rucola_support/core_ext/ruby/object.rb', line 20 def self.extended_class_methods .included_modules.map { |mod| mod.instance_methods }.flatten.uniq end |
.metaclass ⇒ Object
Returns a class’s metaclass.
class FooBar; end
p FooBar. # => #<Class:FooBar>
6 7 8 |
# File 'lib/rucola/rucola_support/core_ext/ruby/object.rb', line 6 def self. class << self; self; end end |
.original_class_methods ⇒ Object
Returns an array of all the class methods that were defined in only this class, so without class methods from any of it’s superclasses or from extending it.
44 45 46 |
# File 'lib/rucola/rucola_support/core_ext/ruby/object.rb', line 44 def self.original_class_methods own_class_methods - extended_class_methods end |
.own_class_methods ⇒ Object
Returns an array of all the class methods that were defined in this class without the ones that were defined in it’s superclasses.
class FooBar
def self.a_original_class_method
end
end
class FooBarSubclass < FooBar
def self.a_original_class_method_in_a_subclass
end
end
FooBarSubclass.own_class_methods # => ['a_original_class_method_in_a_subclass']
38 39 40 |
# File 'lib/rucola/rucola_support/core_ext/ruby/object.rb', line 38 def self.own_class_methods .instance_methods - superclass..instance_methods end |
Instance Method Details
#ivar(name) ⇒ Object
A mocha helper to get at an instance variable without having to use instance_variable_get.
obj.ivar(:some_ivar).expects(:foo)
7 8 9 |
# File 'lib/rucola/test_helper.rb', line 7 def ivar(name) instance_variable_get("@#{name}".to_sym) end |