Last active
September 8, 2015 22:04
-
-
Save a-chernykh/474238c142442ef9914d to your computer and use it in GitHub Desktop.
Interview test task
This file contains 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 Base | |
def initialize(attrs={}) | |
# implement this | |
end | |
def self.find(id) | |
# implements this | |
end | |
def self.db | |
Database.new | |
end | |
def save | |
# implement this | |
end | |
# implement attribute getters | |
# implement attribute setters | |
end |
This file contains 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 Book < Base | |
end |
This file contains 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 Database | |
def select(id) | |
# returns hash or nil | |
end | |
def insert(attrs) | |
# inserts data into DB, returns id | |
end | |
def update(id, attrs) | |
# updates record with given id | |
end | |
end |
This file contains 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
book = Book.new(title: 'Lord of the Rings', pages: 500) | |
book.save | |
book = Book.find(10) | |
puts book.title | |
book.title = 'Another title' | |
book.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment