Skip to content

Instantly share code, notes, and snippets.

@flash-gordon
Last active May 18, 2016 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flash-gordon/00cf090d3c48cd4d5aa69e470a4a1d4d to your computer and use it in GitHub Desktop.
Save flash-gordon/00cf090d3c48cd4d5aa69e470a4a1d4d to your computer and use it in GitHub Desktop.
Class.new(ROM::Repository[relation]) do
defines :mapping
commands :create, update: :by_id, delete: :by_id, mapper: mapping
self.mapping mapping
def find(id)
collection.by_id(id).one
end
def all
collection
end
def collection
root.as(self.class.mapping)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment