inheritance_integer_type 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: 7d78e0cf2ad9168f8669c70150af787c44868b7d
4
- data.tar.gz: 1ddb405db62ab40073071ddbdab26f667ca41a17
3
+ metadata.gz: 24a8dfac2f20647d7ae593cd3c4703585cc3206f
4
+ data.tar.gz: b3740e25777985015bfc3e69bfd1bce1694045ff
5
5
  SHA512:
6
- metadata.gz: 9a0829649261ad317a37c811f10509a9c7d0d9b2159c3e8e0bc7260874e1fcd2a54ffaa55a36ac523a7616df1d7f066caddab125db16cad2976082565f3c6521
7
- data.tar.gz: da7b5968e89cb0dad92dceb217c009ef4af6fad413705f758e70c01f324dc76ba7ed69a7614c8a07b43041a1368f29a317bdbabb90b07c6a59948afe51e9e5b5
6
+ metadata.gz: 9645040244a4a1fdef44d79362ef075e356fdfa2648f36f794045d229b3e1ffc49deef651e52e65fc2c5f0cc7bcbf8e4a49b3dd405aea92685a7091c6368522a
7
+ data.tar.gz: 30bd7e83d396df14f7901e992a9d61dc557b95d79109a414fb9253a43009fd680d8a6b595a22c7172a0a36edfa321ef0ab3d56c63896ea539f3e060dd35bdec8
@@ -16,26 +16,27 @@ module InheritanceIntegerType
16
16
  klass = sti_name_without_integer_types
17
17
  self._inheritance_mapping.key(klass) || klass
18
18
  end
19
-
20
-
21
19
  end
22
20
 
23
21
  included do
24
- class_eval {
25
- cattr_accessor :_inheritance_mapping
22
+ class << self
23
+ def _inheritance_mapping
24
+ @_inheritance_mapping ||= (superclass == ActiveRecord::Base ? {} : superclass._inheritance_mapping.dup)
25
+ end
26
26
 
27
- def self.merge_mapping!(mapping)
27
+ def _inheritance_mapping=(val)
28
+ @_inheritance_mapping = val
29
+ end
30
+
31
+ def merge_mapping!(mapping)
28
32
  conflicts = _inheritance_mapping.keys & mapping.keys
29
33
  raise ArgumentError.new("Duplicate mapping detected for keys: #{conflicts}") if conflicts.any?
30
34
 
31
35
  _inheritance_mapping.merge!(mapping)
32
36
  end
33
37
 
34
- self._inheritance_mapping = {}
35
- class << self
36
- alias_method_chain :sti_name, :integer_types
37
- end
38
- }
38
+ alias_method_chain :sti_name, :integer_types
39
+ end
39
40
  end
40
41
 
41
42
  end
@@ -1,3 +1,3 @@
1
1
  module InheritanceIntegerType
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inheritance_integer_type
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
  - Kyle d'Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.4.3
149
+ rubygems_version: 2.5.2
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Allow the type field in teh DB to be an integer rather than a string