Skip to content

Instantly share code, notes, and snippets.

@sbellware
Last active December 29, 2015 05:29
Show Gist options
  • Select an option

  • Save sbellware/7621966 to your computer and use it in GitHub Desktop.

Select an option

Save sbellware/7621966 to your computer and use it in GitHub Desktop.
class SomeQuery
  include ModelQuery[User]
  
  ...
end

Note

  • ModelQuery is a module
  • User is a class
  • It's a "ModelQuery of User"
  • The syntax is an approximation of parameterized types or generics used in other programming languages
  • Got the idea from Piotr Solnica in his article Subclassing Module For Fun and Profit
  • SomeQuery is just a class that represents an encapsulation of some query logic. It's not germane to demonstrating the technique.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment