Module: Obsidian::Extensions::Object

Defined in:
lib/obsidian/extensions/object.rb

Instance Method Summary collapse

Instance Method Details

#class_def(name, &blk) ⇒ Object

Defines an instance method within a class



23
24
25
# File 'lib/obsidian/extensions/object.rb', line 23

def class_def name, &blk
  class_eval { define_method name, &blk }
end

#meta_def(name, &blk) ⇒ Object

Adds methods to a metaclass



18
19
20
# File 'lib/obsidian/extensions/object.rb', line 18

def meta_def name, &blk
  meta_eval { define_method name, &blk }
end

#meta_eval(&blk) ⇒ Object



13
14
15
# File 'lib/obsidian/extensions/object.rb', line 13

def meta_eval &blk
  metaclass.instance_eval &blk
end

#metaclassObject

The hidden singleton lurks behind everyone



7
8
9
10
11
# File 'lib/obsidian/extensions/object.rb', line 7

def metaclass
  class << self
    self
  end
end