Skip to content

Instantly share code, notes, and snippets.

@tobiashm
Created June 26, 2015 11:59
Show Gist options
  • Select an option

  • Save tobiashm/db711c15d6706cb551d4 to your computer and use it in GitHub Desktop.

Select an option

Save tobiashm/db711c15d6706cb551d4 to your computer and use it in GitHub Desktop.
Dynamic type creation for inheritance
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