storext 0.1.0 → 0.1.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: f75672c4e98e57d8b37ab4bda5442b7defce708f
4
- data.tar.gz: 646b070e850bb86161ff70f574fffc5f92ec9113
3
+ metadata.gz: e93aea5a222f9be204ce5fd3c77e5c19c396372e
4
+ data.tar.gz: ac2067c656576cafe324b8aaa5dc5322ffde4f41
5
5
  SHA512:
6
- metadata.gz: 8be8170eab75249c49086e6c02ae34b358f55b879f34bd02d5f2c4f09faa8821fe1fcb5b2aa68d2c4a163a5161a7749d41b0e593645c609a011d582d344500b8
7
- data.tar.gz: 14c0fea128a4e321f42e02a1067e0392f5b6858e21b410d392bec5ccfba67bf0fd00c1db4e9194df799cdc1b004a9fcb2cdbe785b44556fae2371346ee2d32fe
6
+ metadata.gz: d68794fecd682e4c64814353c812ebc124fb5a31c698bfa17ac0327688d79760b77580f80c1afa18d0dbd96da0a251a410d6c8344b1fb5fc920da364a05f54f7
7
+ data.tar.gz: 2a90a348bde5a70ea084c39fefa19bec9b15d5f42245cf5d5ed34caa8134c01cd2f4beb6a98a7369a1d9f4bf8ab5795ed3037f5d2e4cc8b163135f5d2d77f223
@@ -14,10 +14,31 @@ module Storext
14
14
  unless defined?(self::Boolean)
15
15
  self::Boolean = ::Axiom::Types::Boolean
16
16
  end
17
+
18
+ after_initialize :set_storext_defaults
17
19
  end
18
20
 
21
+
19
22
  private
20
23
 
24
+ def set_storext_defaults
25
+ store_attribute_defs.each do |store_column, store_keys|
26
+ store_keys.each do |store_key|
27
+ set_storext_default_for(store_column, store_key)
28
+ end
29
+ end
30
+ end
31
+
32
+ def set_storext_default_for(column, key)
33
+ if self.send(column).nil? || !self.send(column).has_key?(key.to_s)
34
+ write_store_attribute(column, key, default_store_value(key))
35
+ end
36
+ end
37
+
38
+ def default_store_value(key)
39
+ storext_cast_proxy.send("_casted_#{key}")
40
+ end
41
+
21
42
  def storext_cast_proxy
22
43
  if @storext_cast_proxy
23
44
  return @storext_cast_proxy
@@ -4,15 +4,15 @@ module Storext
4
4
  def storext_define_writer(column, attr)
5
5
  define_method "#{attr}=" do |value|
6
6
  storext_cast_proxy.send("_casted_#{attr}=", value)
7
- write_store_attribute(column,
8
- attr,
9
- storext_cast_proxy.send("_casted_#{attr}"))
7
+ send("#{column}=", send(column) || {})
8
+ send(column)[attr.to_s] = storext_cast_proxy.send("_casted_#{attr}")
10
9
  end
11
10
  end
12
11
 
13
12
  def storext_define_reader(column, attr)
14
13
  define_method attr do
15
- if store_val = read_store_attribute(column, attr)
14
+ if send(column) && send(column).has_key?(attr.to_s)
15
+ store_val = read_store_attribute(column, attr)
16
16
  storext_cast_proxy.send("_casted_#{attr}=", store_val)
17
17
  end
18
18
  storext_cast_proxy.send("_casted_#{attr}")
@@ -1,3 +1,3 @@
1
1
  module Storext
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - G5
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-27 00:00:00.000000000 Z
13
+ date: 2014-11-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -68,6 +68,20 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: database_cleaner
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
71
85
  description: Extends ActiveRecord::Store.store_accessor
72
86
  email:
73
87
  - lateam@getg5.com