nullify_empty 0.1.2 → 0.1.3

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: db799c587efb2abc57083a9783e3fabce13928b1
4
- data.tar.gz: 650ffce2ba63acc8c339055badde98b50e0077d1
3
+ metadata.gz: b93d71b3a4e195aa148e11322720e1f214a69e66
4
+ data.tar.gz: bf086d72770a6524c24952a6e2743e3f0ff75872
5
5
  SHA512:
6
- metadata.gz: 492428f98f4d5b0d0ab8b8e7b06b124a95caec2cbd04de179c5fe0f350ff914c29b3b44d8b8184e89fa695b0737b9d0593f73fef64363cefb0212bfe8f3836af
7
- data.tar.gz: 4fbfffda74ac177f900dca786074d201de816c52eb89f72c51238ad548bfe10fa52adeb39b16f9b1be2aa85b179b325300cd70fa9352dd79bc8182ba8b03cb78
6
+ metadata.gz: 8036a803f7d1b8f63ea6cb823aff3d130fda48a2e51b991df67186a25b7e99ed137ce650a78df8c4dc7a4c77a0ecddba96c9f485d4f8caae8dea0b9ba227b2f1
7
+ data.tar.gz: 0ee43fd8ba4d6abfd435be2aac3199a78abb1f940c7fb66f2f736dc131caf71bb2440ae6e5f0d8bd7ce2a915573381e6adda960b03301c82bad9221d5886d05b
@@ -8,9 +8,12 @@ module NullifyEmpty
8
8
 
9
9
  new_type_klass =
10
10
  NULLIFY_EMPTY_TYPES.find { |_, klass| klass.superclass == original_type_klass }.first
11
+ next unless new_type_klass
11
12
 
12
13
  attribute attr_name, new_type_klass
13
14
  end
15
+ rescue
16
+ # ignore
14
17
  end
15
18
  end
16
19
  end
@@ -2,15 +2,15 @@ module NullifyEmpty
2
2
  class NullifyEmptyStringType < ActiveRecord::Type::String; end
3
3
  class NullifyEmptyTextType < ActiveRecord::Type::Text; end
4
4
 
5
- NULLIFY_EMPTY_TYPES = {nullify_empty_string: NullifyEmptyStringType,
6
- nullify_empty_text: NullifyEmptyTextType}
7
-
5
+ NULLIFY_EMPTY_TYPES = {nullify_empty_string: NullifyEmptyStringType,
6
+ nullify_empty_text: NullifyEmptyTextType}.freeze
7
+
8
8
  NULLIFY_EMPTY_TYPES.values.each do |klass|
9
9
  klass.class_eval do
10
10
  def cast(value)
11
11
  value = nil if value.respond_to?(:empty?) && value.empty?
12
12
  super value
13
- end
13
+ end
14
14
  end
15
- end
15
+ end
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module NullifyEmpty
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nullify_empty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Chumakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-09 00:00:00.000000000 Z
11
+ date: 2019-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.6.11
112
+ rubygems_version: 2.6.13
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Store empty values as NULL in DB.