virtualize 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/virtualize.rb +11 -0
- data/lib/virtualize/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b59f0fbfa4e111f5cc7efb76f249799dd831360
|
4
|
+
data.tar.gz: 9ae66c4e963180fbb6fc317b68412991bbda11c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f780cf2f76e11d829ac0ce3359630326b76371f101501cbea03201fd63b54b0fdf3921bef02a7caa41965418ddde6740fe59c1bcae3980963242916bce442e9b
|
7
|
+
data.tar.gz: 11e65ec99a998b54b2bd088064389d9770c6c082e8fedfeca13ac59e52cf275b6de2032b908ba6b076faee9c1709a0d8e0bb08618846e88a94a4538aea6d667f
|
data/lib/virtualize.rb
CHANGED
@@ -9,6 +9,8 @@ module Virtualize
|
|
9
9
|
options = { on: 'data' }.merge(options)
|
10
10
|
column_name = options[:on]
|
11
11
|
attributes = args
|
12
|
+
@virtual_column = column_name
|
13
|
+
@virtual_attributes = attributes
|
12
14
|
serialize column_name
|
13
15
|
|
14
16
|
define_method 'virtual_data' do
|
@@ -28,4 +30,13 @@ module Virtualize
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
def attributes
|
35
|
+
hash = super
|
36
|
+
hash.delete(self.class.instance_variable_get(:@virtual_column).to_s)
|
37
|
+
self.class.instance_variable_get(:@virtual_attributes).each do |virtual_key|
|
38
|
+
hash[virtual_key.to_s] = send(virtual_key)
|
39
|
+
end
|
40
|
+
hash
|
41
|
+
end
|
31
42
|
end
|
data/lib/virtualize/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virtualize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kotohata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
|
-
rubygems_version: 2.
|
76
|
+
rubygems_version: 2.6.2
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: ActiveRecord virtual attribute support.
|