evt-schema 0.7.0.0 → 0.7.1.0

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
  SHA256:
3
- metadata.gz: 60e3c1e13116174d55550ae35739221a99d7878c0cbe5a4cec5145659dd88d90
4
- data.tar.gz: 3696f93ba1ed3b49010af921cfec7ae0909ea27e6a99e9ab5407ee2d3b0188f4
3
+ metadata.gz: a0baf84136be9780d8859e47452b4c592ad40a0c368c40b39bdf545520e64035
4
+ data.tar.gz: e4f7954206992334b5e6a7239c69062bcb1bcb9d2d7d3e5cea47926eac777b45
5
5
  SHA512:
6
- metadata.gz: f0243cf5794000a89cf22a615a146e9b773195d0e408896d1e4313393015851142047dc0aa48ab0ea2e09b6ac0a197a5456db4f6be09ed3c22998f0e9b0e99f3
7
- data.tar.gz: 30ce700826b0dc389c1a561e02cfa9e3db22d6b19adc81acabcf0bc325863b1a893d538dfe1946b9e9bcc764ae27fda53992e4a9c81ff917e85dd818cda74412
6
+ metadata.gz: b2ff163388c5de0bf45328bfa5d1701d8bd494ab246334b78775cdad48f1e11bbd2ceee7f38c88dec4c6edca9b19051079261fa0f987f69ea1d6106f5331fdc0
7
+ data.tar.gz: b50216b2d6f991c7e2d7066f804c23bb1f824d5d881ae22694e55678dc0f9221a0c6751337b12068f0f7033f3cc551b884216f7462004ad50aef24dc1a8536b1
@@ -108,6 +108,17 @@ module Schema
108
108
  end
109
109
  end
110
110
 
111
+ module Boolean
112
+ def self.example
113
+ Example.new
114
+ end
115
+
116
+ class Example
117
+ include ::Schema
118
+ attribute :some_boolean_attribute, Boolean
119
+ end
120
+ end
121
+
111
122
  module Duplicate
112
123
  def self.example
113
124
  Example.new
@@ -5,6 +5,8 @@ module Schema
5
5
  cls.class_exec do
6
6
  extend AttributeMacro
7
7
  extend Attributes
8
+
9
+ const_set(:Boolean, Boolean)
8
10
  end
9
11
  end
10
12
 
@@ -14,10 +16,23 @@ module Schema
14
16
  raise Schema::Attribute::Error, "The \"#{attr_name}\" attribute is declared with the \"strict\" option but a type is not specified"
15
17
  end
16
18
 
17
- strict ||= false
19
+ if type == Boolean && strict == false
20
+ raise Schema::Attribute::Error, "The \"#{attr_name}\" attribute is declared with the \"strict\" option disabled but boolean type is specified"
21
+ end
22
+
18
23
  check = nil
19
24
 
20
- unless type.nil?
25
+ if type == Boolean
26
+ strict ||= true
27
+
28
+ check = proc do |val|
29
+ unless val.nil? || Boolean.(val)
30
+ raise Schema::Attribute::TypeError, "#{val.inspect} is not a boolean"
31
+ end
32
+ end
33
+ elsif !type.nil?
34
+ strict ||= false
35
+
21
36
  check = proc do |val|
22
37
  unless val.nil?
23
38
  if strict
@@ -116,6 +131,12 @@ module Schema
116
131
  end
117
132
  end
118
133
 
134
+ module Boolean
135
+ def self.call(val)
136
+ val == true || val == false
137
+ end
138
+ end
139
+
119
140
  def attributes
120
141
  transient_attributes = []
121
142
  if self.class.respond_to?(:transient_attributes)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.0
4
+ version: 0.7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-24 00:00:00.000000000 Z
11
+ date: 2018-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-attribute
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.7.3
119
+ rubygems_version: 2.7.6
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Primitives for schema and structure