Skip to content

Instantly share code, notes, and snippets.

@davidbalbert
Last active December 31, 2015 20:49
Show Gist options
  • Save davidbalbert/8042981 to your computer and use it in GitHub Desktop.
Save davidbalbert/8042981 to your computer and use it in GitHub Desktop.
A bad idea
module CreatedAt
module ClassMixin
def new(*)
obj = super
obj.instance_variable_set(:@_created_at, Time.now)
obj
end
end
module ObjectMixin
def created_at
@_created_at
end
end
end
class Class
prepend CreatedAt::ClassMixin
end
class Object
include CreatedAt::ObjectMixin
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment