Skip to content

Instantly share code, notes, and snippets.

@sgrif
Created Oct 6, 2015
Embed
What would you like to do?
class LazilyDefineAttributes < Module
def initialize(attribute_definition)
define_method(:method_missing) do |method_name, *args, &block|
attribute_defintion
end
end
end
class Foo
end
Foo.include(LazilyDefineAttributes.new(:foo))
require "minitest/autorun"
class TestStuff < Minitest::Test
def test_stuff
Foo.new.asdfasdkfj
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment