virtualize 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82f0741a7e70d347ac8cc69725856db2bd63de77
4
- data.tar.gz: 1c09c63023f01c684a04dc161d2d80a1abcf31ef
3
+ metadata.gz: 4b59f0fbfa4e111f5cc7efb76f249799dd831360
4
+ data.tar.gz: 9ae66c4e963180fbb6fc317b68412991bbda11c9
5
5
  SHA512:
6
- metadata.gz: 9eef6631016d51d5fe088e5e53cdc208a6e86b417d862b4119817c036ff4f5b88e3dbd840a19dc42354830c61a08a27f32786c14c8a26b2f5d08efc7400475b9
7
- data.tar.gz: 30198d69dccc2a0b11f09cb7b252e503c2561ced8deccb9e455ff3914007cd522e9fcacc143a33cdcbed297a3593dd2a73e026af0103dc1c3886ac96f7be2079
6
+ metadata.gz: f780cf2f76e11d829ac0ce3359630326b76371f101501cbea03201fd63b54b0fdf3921bef02a7caa41965418ddde6740fe59c1bcae3980963242916bce442e9b
7
+ data.tar.gz: 11e65ec99a998b54b2bd088064389d9770c6c082e8fedfeca13ac59e52cf275b6de2032b908ba6b076faee9c1709a0d8e0bb08618846e88a94a4538aea6d667f
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Virtualize
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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: 2015-10-06 00:00:00.000000000 Z
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.2.2
76
+ rubygems_version: 2.6.2
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: ActiveRecord virtual attribute support.