type_validator 0.7.0 → 0.8.0

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
  SHA256:
3
- metadata.gz: 16bbf2c1f264c32540b3a2a0b455dc14a5b808a85ff17ab2f2774070ac7a95a2
4
- data.tar.gz: a7c6e27a77306aa5b79b9040c8823bb5da18d5bcd2e807b1de1b1a1f7f0c982a
3
+ metadata.gz: 96d8db1bdc2cb03f7eddc41fb66025b36557fc83014845868a847b118f521d14
4
+ data.tar.gz: f1d2f58f64b062855ccb490332064b7b9a0f82162b1e0246d48eaa534a305961
5
5
  SHA512:
6
- metadata.gz: 67949f5d4714cb33c9d2c6d759361993d0b28426644bacde350a86f597849e8313d13083d15abc046da4e03fe57226b9a6679dfc46b623be65f2f30ace13d672
7
- data.tar.gz: 94af44dc82dbb1c52cbc2a7ea109e29d997db51a91852e409a7e2a5c1843aeb6e61fa353cc3a25e42f6305fed93b9f4646f2ac308aaacb45779f0a13777801d3
6
+ metadata.gz: 1f6812a3e4dda60eb1157b42aa5553b2b1b4edce6df26b261d85fecc27be4dbba1fd334dd9628a4a33a97f318ddbdffb48f9fd8ad35160b98087a3087a103661
7
+ data.tar.gz: 4cbd56e7a43b563f9482176e24060842386d58d59d893c918042fe4cbc0df1417b8cc88317176e0abecb6fcf7b8878975dc5a93962fb83d1f403e19b3a15a6e7
@@ -16,13 +16,15 @@ class TypeValidator < ActiveModel::EachValidator
16
16
  record.errors.add(attribute, error)
17
17
  end
18
18
 
19
- def fetch_strategy(options)
20
- return ByKindOf if options.key?(:is_a) || options.key?(:kind_of)
21
- return ByRespondTo if options.key?(:respond_to)
22
- return ByKlass if options.key?(:klass)
23
- return ByArrayOf if options.key?(:array_of)
24
- return ByArrayWith if options.key?(:array_with)
25
- end
19
+ private
20
+
21
+ def fetch_strategy(options)
22
+ return ByKindOf if options.key?(:is_a) || options.key?(:kind_of)
23
+ return ByRespondTo if options.key?(:respond_to)
24
+ return ByKlass if options.key?(:klass)
25
+ return ByArrayOf if options.key?(:array_of)
26
+ return ByArrayWith if options.key?(:array_with)
27
+ end
26
28
  end
27
29
 
28
30
  require 'type_validator/version'
@@ -3,7 +3,7 @@
3
3
  require 'active_model'
4
4
 
5
5
  class TypeValidator
6
- class ByArrayOf
6
+ module ByArrayOf
7
7
  def self.invalid?(value, options)
8
8
  types = Array(options[:array_of])
9
9
 
@@ -3,7 +3,7 @@
3
3
  require 'active_model'
4
4
 
5
5
  class TypeValidator
6
- class ByArrayWith
6
+ module ByArrayWith
7
7
  def self.invalid?(value, options)
8
8
  expected = options[:array_with]
9
9
 
@@ -3,7 +3,7 @@
3
3
  require 'active_model'
4
4
 
5
5
  class TypeValidator
6
- class ByKindOf
6
+ module ByKindOf
7
7
  def self.invalid?(value, options)
8
8
  types = Array(options[:is_a] || options[:kind_of])
9
9
 
@@ -3,7 +3,7 @@
3
3
  require 'active_model'
4
4
 
5
5
  class TypeValidator
6
- class ByKlass
6
+ module ByKlass
7
7
  def self.invalid?(value, options)
8
8
  klass = options[:klass]
9
9
 
@@ -3,7 +3,7 @@
3
3
  require 'active_model'
4
4
 
5
5
  class TypeValidator
6
- class ByRespondTo
6
+ module ByRespondTo
7
7
  def self.invalid?(value, options)
8
8
  method_name = options[:respond_to]
9
9
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TypeValidator
4
- VERSION = '0.7.0'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Serradura