Created
June 23, 2013 22:44
-
-
Save joenoon/5846816 to your computer and use it in GitHub Desktop.
YapModel, coming soon
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 YapModel | |
def self.database | |
Dispatch.once { @database = YapDatabase.alloc.initWithPath(App.documents_path + "/yap.db") } | |
@database | |
end | |
def self.dbconnection | |
Thread.current["yap_dbconnection"] ||= WeakRef.new(new_dbconnection) | |
end | |
def self.new_dbconnection | |
YapModel.database.newConnection | |
end | |
attr_writer :dbconnection | |
def dbconnection | |
@dbconnection || self.class.dbconnection | |
end | |
# more to come, work in progress... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment