constrain 0.1.1 → 0.1.2

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: ef3357b49faba9f9d3bfe5dbfb3d27b70d1493456b4dea29afb96c811b4eff8b
4
- data.tar.gz: 590bb604f5566f76d4473f1f9191ef2ca21bfdcf9a904b92a0b6fa0388263c12
3
+ metadata.gz: bc16332a51e4f45dabe31a86b2e21bfeed6f54f11310c026609184c0cd28b577
4
+ data.tar.gz: 3f88e7f7c97fb7dd925191274d89366729e53b4e5fba2f2628b197f4f7bb6664
5
5
  SHA512:
6
- metadata.gz: ec0d44e4cb0a7b4c3c8291bc10d821000769d36fe30c44aed85c30b3993076796169f7efa394cd47b0694744b47e6354e7413fb1c8b3a814d3a42d91cdeff04d
7
- data.tar.gz: 9b60ecec9cb4edd2dc507b10835df150094b9fc3a939735be6935a93df4d5f049bbf4fe963eebb7ebf07a4faf21fa13cf3908a4ea44ac93178f97ef9b29d2612
6
+ metadata.gz: 06fb09ab023fe14278efd1adda85af85c4b1649cc78923d56ffbd0e5634c9508931e22b762c8a305b369ef0d0de56d04223b6fbada6649a19e7558002c313090
7
+ data.tar.gz: 156bed0099e954c53c4cad966c2a55731b49639058748bda9de01fbf1ff8348a6c7a0b0b2723e569e2d578319bb6fd0b6ad1aa5b23afa7334f609410b55cdb4f
data/README.md CHANGED
@@ -84,12 +84,13 @@ or false as result
84
84
  ## Class Expressions
85
85
 
86
86
  Constrain#constrain and Constrain::check use class expressions composed of
87
- Class objects, Proc objects, or arrays and hashes of class expressions. Class
88
- objects match if the value is an instance of the class:
87
+ class or module objects, Proc objects, or arrays and hashes of class expressions. Class or module
88
+ objects match if `value.is_a?(class_or_module)` returns true:
89
89
 
90
90
  ```ruby
91
- constrain 42, Integer # Success
92
- constrain 42, String # Failure
91
+ constrain 42, Integer # Success
92
+ constrain 42, Comparable # Success
93
+ constrain nil, Comparable # Failure
93
94
  ```
94
95
 
95
96
  More than one class expression is allowed. It matches if at least one of the expressions match:
data/lib/constrain.rb CHANGED
@@ -29,7 +29,7 @@ module Constrain
29
29
  # Constrain::Error if the expression is invalid
30
30
  def self.check(value, expr)
31
31
  case expr
32
- when Class
32
+ when Class, Module
33
33
  value.is_a?(expr)
34
34
  when Array
35
35
  !expr.empty? or raise Error, "Empty array"
@@ -1,3 +1,3 @@
1
1
  module Constrain
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-16 00:00:00.000000000 Z
11
+ date: 2021-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov