Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sgrif
Created October 6, 2015 21:52
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 sgrif/720b7473c5ce9a51d6e2 to your computer and use it in GitHub Desktop.
Save sgrif/720b7473c5ce9a51d6e2 to your computer and use it in GitHub Desktop.
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