Skip to content

Instantly share code, notes, and snippets.

@zdavatz
Created March 16, 2011 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdavatz/872173 to your computer and use it in GitHub Desktop.
Save zdavatz/872173 to your computer and use it in GitHub Desktop.
persistable.rb
class Object # :nodoc: all
def odba_id
end
def odba_instance
self
end
def odba_isolated_stub
self
end
def metaclass; class << self; self; end; end
def meta_eval &blk; metaclass.instance_eval &blk; end
end
@mhatakeyama
Copy link

def metaclass
class << self
self
end
end

def meta_eval(&blk)
metaclass.instance_eval(&blk)
end

@mhatakeyama
Copy link

class Object
def metaclass
class << self
self
end
end
def meta_eval(&blk)
metaclass.instance_eval(&blk)
end
end

class Test
end

test = Test.new
test.meta_eval do
define_method('hello') do
p 'hello'
end
end

test.hello

test2 = Test.new
test2.hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment