Skip to content

Instantly share code, notes, and snippets.

@ernie
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ernie/fbf9785c6cee5a96690e to your computer and use it in GitHub Desktop.
Save ernie/fbf9785c6cee5a96690e to your computer and use it in GitHub Desktop.
class PersonRepository < Norm::PostgreSQLRepository
def named(name)
select_records(select_statement.where(:name => name))
end
def select_statement
Norm::SQL.select.from('people')
end
def insert_statement
column_list = record_class.attribute_names.join(', ')
Norm::SQL.insert("people (#{column_list})").returning('*')
end
def update_statement
Norm::SQL.update('people').returning('*')
end
def delete_statement
Norm::SQL.delete('people').returning('*')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment