Created
June 26, 2015 11:59
-
-
Save tobiashm/db711c15d6706cb551d4 to your computer and use it in GitHub Desktop.
Dynamic type creation for inheritance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Task | |
| def model | |
| fail "Must be implemented in sub-class" | |
| end | |
| # ... | |
| end | |
| def Task(model) | |
| Class.new(Task) { cattr_reader :model; @model = model } | |
| end | |
| class FooTask < Task(Foo) | |
| # ... | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment