duck_record 0.0.23 → 0.0.24

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: bc4554980a2453870fa71616cd56279ce83b5454
4
- data.tar.gz: 0e62dba8f62514499fc95fe75a9f24548e93f6ed
3
+ metadata.gz: cabf3726f7d003f3207bd5da1a536d1a4cc4b0ea
4
+ data.tar.gz: 61604634b3ae7ad953172a00d190012a37c430a0
5
5
  SHA512:
6
- metadata.gz: 3c4bdf7e498269309f56201a3f605d5939202561bafdbd106efebbd4c5f8d8c86a6bf2607c5678d04ef0beba5654b805c53ee75dcfb930dcb2cbeb8cf22f4930
7
- data.tar.gz: d1f951ff91b996436acb2a244b3f8bf3cee8bdd58f742c31e968465f1c531818ec4a4f97b8dfc0fb1865751c39a8235967ae445ebbdeaf50e74b37b929c69d4c
6
+ metadata.gz: 6a3e6595e975d36d0e70e162b1b986e564831f8b42240c1d9e09a164518bb7ee32ccbd4acf95d89370a0e29f89ed4ef598c5369f9d48ecc45e9ff42798e774be
7
+ data.tar.gz: b868f9688ce9fbabdd37ea6069f4636a5fa31f68eda6684d0072ad4b2dd2d51970a4664c0f5e3e7f6728bd7a57e5918dac4f1c0110c19b1f8f6bb89ca074b4c3
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_model/validations/clusivity"
4
-
5
3
  module DuckRecord
6
4
  module Validations
7
5
  class SubsetValidator < ActiveModel::EachValidator # :nodoc:
8
- include ActiveModel::Validations::Clusivity
6
+ ERROR_MESSAGE = "An object with the method #include? or a proc, lambda or symbol is required, " \
7
+ "and must be supplied as the :in (or :within) option of the configuration hash"
8
+
9
+ def check_validity!
10
+ unless delimiter.respond_to?(:include?) || delimiter.respond_to?(:call) || delimiter.respond_to?(:to_sym)
11
+ raise ArgumentError, ERROR_MESSAGE
12
+ end
13
+ end
9
14
 
10
15
  def validate_each(record, attribute, value)
11
16
  unless subset?(record, value)
@@ -15,6 +20,10 @@ module DuckRecord
15
20
 
16
21
  private
17
22
 
23
+ def delimiter
24
+ @delimiter ||= options[:in] || options[:within]
25
+ end
26
+
18
27
  def subset?(record, value)
19
28
  return false unless value.respond_to?(:to_a)
20
29
 
@@ -1,3 +1,3 @@
1
1
  module DuckRecord
2
- VERSION = "0.0.23"
2
+ VERSION = "0.0.24"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duck_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl