swiss_db 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/swiss_db/data_store.rb +14 -2
- data/lib/swiss_db/db.rb +1 -1
- data/lib/swiss_db/swiss_model.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4493439407074a5f0f206937592af34b266bf4f
|
4
|
+
data.tar.gz: d4194cddea16159f767e06affdf26a54a179ef03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 575b7f2dc6ab2517b08392e8d86901d7699c11d2d552bedffc95e5f4ff810f550c372171a164276ae5163939e3cb07a353d7423babf19f2445bfbe5e7cd62910
|
7
|
+
data.tar.gz: c42394a1d37094fb2286090e0afa8bf8eb766b242837771e860a12ca950394b5bd10368c78ca9d7642394f5cc88c321f038977e2acb35ed1d2cad0f53ee81e0b
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ class Model < SwissModel
|
|
37
37
|
end
|
38
38
|
```
|
39
39
|
|
40
|
-
|
40
|
+
Set the context in your bluepotion_application.rb.
|
41
41
|
|
42
42
|
```ruby
|
43
43
|
class BluePotionApplication < PMApplication
|
@@ -45,7 +45,7 @@ class BluePotionApplication < PMApplication
|
|
45
45
|
home_screen HomeScreen
|
46
46
|
|
47
47
|
def on_create
|
48
|
-
|
48
|
+
DataStore.context = self
|
49
49
|
end
|
50
50
|
end
|
51
51
|
```
|
data/lib/swiss_db/data_store.rb
CHANGED
@@ -8,12 +8,24 @@
|
|
8
8
|
DATABASE_VERSION = 1
|
9
9
|
ContentValues = Android::Content::ContentValues
|
10
10
|
|
11
|
+
def self.current_schema=(schema)
|
12
|
+
@@current_schema = schema
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.context=(context)
|
16
|
+
@@context = context
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.context
|
20
|
+
@@context
|
21
|
+
end
|
22
|
+
|
11
23
|
def writable_db
|
12
24
|
getWritableDatabase
|
13
25
|
end
|
14
26
|
|
15
27
|
def drop_db
|
16
|
-
|
28
|
+
@@context.deleteDatabase(DATABASE_NAME)
|
17
29
|
end
|
18
30
|
|
19
31
|
def onUpgrade(db, oldVersion, newVersion)
|
@@ -29,7 +41,7 @@
|
|
29
41
|
# NOTE: I don't know a better way of passing the schema here
|
30
42
|
# If you do just change it. For now this works.
|
31
43
|
# Thanks.
|
32
|
-
|
44
|
+
@@current_schema.each do |k, v|
|
33
45
|
create_table db, k, v
|
34
46
|
end
|
35
47
|
# database.execSQL("CREATE TABLE credentials(username TEXT, password TEXT)")
|
data/lib/swiss_db/db.rb
CHANGED
@@ -35,7 +35,7 @@ class Object
|
|
35
35
|
@table_name = table_name
|
36
36
|
@current_schema[@table_name] = {}
|
37
37
|
block.call
|
38
|
-
|
38
|
+
DataStore.current_schema = @current_schema # there was no other way. I couldn't get context to create the model here.
|
39
39
|
end
|
40
40
|
|
41
41
|
def add_column(name, type)
|
data/lib/swiss_db/swiss_model.rb
CHANGED