storext 0.2.1 → 1.0.0
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 +2 -2
- data/lib/storext/class_methods.rb +3 -3
- data/lib/storext/instance_methods.rb +15 -3
- data/lib/storext/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41501e45ad81d0210775629539268c73a96d98a0
|
4
|
+
data.tar.gz: e775e1155ae76dda7b5098920a366b74fe794724
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64f397db35f2cde3086cc7a8b6102c818fd83a8dedb712b1d6e401609a3f4201cf9b28a30725eed0665d8531f49778b8f12cb96382b2dc47e6f2ed6475b3b4aa
|
7
|
+
data.tar.gz: fbce44911c14449ca9a2015bd0107180fb0d76aea197c48e9ef33836a1b06e740899d2c5c882a2d3e18c84a5ce4952debf28a257eec4f843270ef492bf969d1e
|
data/lib/storext.rb
CHANGED
@@ -33,8 +33,8 @@ module Storext
|
|
33
33
|
self.storext_options = {}
|
34
34
|
end
|
35
35
|
|
36
|
-
class_attribute :
|
37
|
-
self.
|
36
|
+
class_attribute :storext_definitions
|
37
|
+
self.storext_definitions = {}
|
38
38
|
|
39
39
|
unless defined?(self::Boolean)
|
40
40
|
self::Boolean = ::Axiom::Types::Boolean
|
@@ -42,16 +42,16 @@ module Storext
|
|
42
42
|
|
43
43
|
def storext_attrs_for(column)
|
44
44
|
attrs = []
|
45
|
-
|
45
|
+
storext_definitions.each do |attr, definition|
|
46
46
|
attrs << attr if definition[:column] == column
|
47
47
|
end
|
48
48
|
attrs
|
49
49
|
end
|
50
50
|
|
51
51
|
def track_store_attribute(column, attr, type, opts)
|
52
|
-
self.
|
52
|
+
self.storext_definitions = self.storext_definitions.dup
|
53
53
|
|
54
|
-
|
54
|
+
storext_definitions[attr] = {
|
55
55
|
column: column,
|
56
56
|
type: type,
|
57
57
|
opts: opts,
|
@@ -1,6 +1,18 @@
|
|
1
1
|
module Storext
|
2
2
|
module InstanceMethods
|
3
3
|
|
4
|
+
def destroy_key(column, attr)
|
5
|
+
new_value = send(column)
|
6
|
+
new_value.delete(attr.to_s)
|
7
|
+
send("#{column}=", new_value)
|
8
|
+
end
|
9
|
+
|
10
|
+
def destroy_keys(column, *attrs)
|
11
|
+
new_value = send(column)
|
12
|
+
attrs.each { |a| new_value.delete(a.to_s) }
|
13
|
+
send("#{column}=", new_value)
|
14
|
+
end
|
15
|
+
|
4
16
|
private
|
5
17
|
|
6
18
|
def set_storext_defaults
|
@@ -8,7 +20,7 @@ module Storext
|
|
8
20
|
self.send("#{column}=", default) if self.send(column).nil?
|
9
21
|
end
|
10
22
|
|
11
|
-
|
23
|
+
storext_definitions.each do |attr, definition|
|
12
24
|
set_storext_default_for(definition[:column], attr)
|
13
25
|
end
|
14
26
|
end
|
@@ -35,8 +47,8 @@ module Storext
|
|
35
47
|
|
36
48
|
klass.attribute(
|
37
49
|
"casted_attr",
|
38
|
-
self.class.
|
39
|
-
self.class.
|
50
|
+
self.class.storext_definitions[attr][:type],
|
51
|
+
self.class.storext_definitions[attr][:opts],
|
40
52
|
)
|
41
53
|
|
42
54
|
@storext_cast_proxies[attr] = klass.new
|
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.
|
4
|
+
version: 1.0.0
|
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: 2015-
|
13
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|