Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created June 9, 2014 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sideshowcoder/a714de4e703ef1b9feaf to your computer and use it in GitHub Desktop.
Save sideshowcoder/a714de4e703ef1b9feaf to your computer and use it in GitHub Desktop.
Getting data into CouchbaseLite via Ruby
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