Last active
August 29, 2015 14:01
-
-
Save ernie/fbf9785c6cee5a96690e to your computer and use it in GitHub Desktop.
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 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