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 +4 -4
- data/lib/storext.rb +21 -0
- data/lib/storext/class_methods.rb +4 -4
- data/lib/storext/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e93aea5a222f9be204ce5fd3c77e5c19c396372e
|
4
|
+
data.tar.gz: ac2067c656576cafe324b8aaa5dc5322ffde4f41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d68794fecd682e4c64814353c812ebc124fb5a31c698bfa17ac0327688d79760b77580f80c1afa18d0dbd96da0a251a410d6c8344b1fb5fc920da364a05f54f7
|
7
|
+
data.tar.gz: 2a90a348bde5a70ea084c39fefa19bec9b15d5f42245cf5d5ed34caa8134c01cd2f4beb6a98a7369a1d9f4bf8ab5795ed3037f5d2e4cc8b163135f5d2d77f223
|
data/lib/storext.rb
CHANGED
@@ -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
|
-
|
8
|
-
|
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
|
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}")
|
data/lib/storext/version.rb
CHANGED
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.
|
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-
|
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
|