Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/ext/metaclass.rb,
lib/ext/object.rb
Overview
Class Method Summary collapse
-
.unique_methods ⇒ Object
Lists methods unique to a class.
Instance Method Summary collapse
-
#args_and_opts(*args) ⇒ Object
Returns a list of arguments and an options hash.
-
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class.
-
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass.
- #meta_eval(&blk) ⇒ Object
-
#metaclass ⇒ Object
The hidden singleton lurks behind everyone.
-
#unique_methods ⇒ Object
Lists methods unique to an instance.
Class Method Details
Instance Method Details
#args_and_opts(*args) ⇒ Object
Returns a list of arguments and an options hash. Source taken from RSpec.
13 14 15 16 |
# File 'lib/ext/object.rb', line 13 def args_and_opts(*args) = Hash === args.last ? args.pop : {} return args, end |
#class_def(name, &blk) ⇒ Object
Defines an instance method within a class
14 15 16 |
# File 'lib/ext/metaclass.rb', line 14 def class_def name, &blk class_eval { define_method name, &blk } end |
#meta_def(name, &blk) ⇒ Object
Adds methods to a metaclass
9 10 11 |
# File 'lib/ext/metaclass.rb', line 9 def name, &blk { define_method name, &blk } end |
#meta_eval(&blk) ⇒ Object
6 |
# File 'lib/ext/metaclass.rb', line 6 def (&blk); .instance_eval(&blk); end |
#metaclass ⇒ Object
The hidden singleton lurks behind everyone
5 |
# File 'lib/ext/metaclass.rb', line 5 def ; class << self; self; end; end |