swiss_db 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e116c10e8cc3bd87e03a39c0070503942d9705e5
4
- data.tar.gz: 772ccee76d341e64f1d86cdaa6270ef3edef91a2
3
+ metadata.gz: b4493439407074a5f0f206937592af34b266bf4f
4
+ data.tar.gz: d4194cddea16159f767e06affdf26a54a179ef03
5
5
  SHA512:
6
- metadata.gz: 9ec1a9330cc0b83769f4e07e710679ee1ab06f8ef2b1598d79806877b7a6b8213a8a24d7861d8885e85271ecf0f53ddc49c93f48cd38ba26dc4c6077b439b1b7
7
- data.tar.gz: c222afa056499b831c5547c57a8777d1d4de71f60e74a243ebb91a02900edaeb958588519b5e1c51e93c6b5c5e826c98703b7ca99782d20b4a67e847aa49eb8c
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
- Don't forget to set $app_context in your bluepotion_application.rb. Don't panic. This won't be a global in the next release.
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
- $app_context = self
48
+ DataStore.context = self
49
49
  end
50
50
  end
51
51
  ```
@@ -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
- $app_context.deleteDatabase(DATABASE_NAME)
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
- $current_schema.each do |k, v|
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
- $current_schema = @current_schema # there was no other way. I couldn't get context to create the model here.
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)
@@ -12,7 +12,8 @@ class SwissModel
12
12
  # attr_accessor :table_name
13
13
 
14
14
  def self.store
15
- @store ||= DataStore.new($app_context)
15
+ context = DataStore.context
16
+ @store ||= DataStore.new(context)
16
17
  @store
17
18
  end
18
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiss_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Silverman