Created
June 9, 2014 11:02
-
-
Save sideshowcoder/a714de4e703ef1b9feaf to your computer and use it in GitHub Desktop.
Getting data into CouchbaseLite via Ruby
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 Item < CBLModel | |
attr_reader :created_at | |
def self.docType | |
"item" | |
end | |
def initInDatabase database, withTitle: title | |
self.initWithNewDocumentInDatabase database | |
self.setValue(self.class.docType, ofProperty: "type") | |
self.title = title | |
self.created_at = NSDate.date | |
self | |
end | |
def title | |
getValueOfProperty "title" | |
end | |
def title= new_title | |
self.setValue(new_title, ofProperty: "title") | |
end | |
def created_at= date | |
self.setValue(date, ofProperty: "created_at") | |
end | |
def to_s | |
"#{self.class}[#{document.abbreviatedID}, #{title}]" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment