schematic 0.3.4 → 0.3.5
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.
@@ -4,6 +4,7 @@ module Schematic
|
|
4
4
|
class Enumeration < Base
|
5
5
|
def generate(builder)
|
6
6
|
for_validator ActiveModel::Validations::InclusionValidator do |validator|
|
7
|
+
next if column.type == :boolean
|
7
8
|
validator.options[:in].each do |value|
|
8
9
|
builder.xs(:enumeration, "value" => value)
|
9
10
|
end
|
data/lib/schematic/version.rb
CHANGED
@@ -7,10 +7,12 @@ describe Schematic::Generator::Restrictions::Enumeration do
|
|
7
7
|
with_model :enumeration_model do
|
8
8
|
table :id => false do |t|
|
9
9
|
t.string "title"
|
10
|
+
t.boolean "active"
|
10
11
|
end
|
11
12
|
|
12
13
|
model do
|
13
14
|
validates :title, :inclusion => { :in => ["a", "b", "c"] }
|
15
|
+
validates :active, :inclusion => { :in => [true, false] }
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -20,7 +22,7 @@ describe Schematic::Generator::Restrictions::Enumeration do
|
|
20
22
|
lambda {
|
21
23
|
validate_xml_against_xsd(xml, subject)
|
22
24
|
}.should raise_error
|
23
|
-
valid_instance = EnumerationModel.new(:title => "a")
|
25
|
+
valid_instance = EnumerationModel.new(:title => "a", :active => true)
|
24
26
|
xml = [valid_instance].to_xml
|
25
27
|
lambda {
|
26
28
|
validate_xml_against_xsd(xml, subject)
|
@@ -41,6 +43,14 @@ describe Schematic::Generator::Restrictions::Enumeration do
|
|
41
43
|
</xs:simpleContent>
|
42
44
|
</xs:complexType>
|
43
45
|
</xs:element>
|
46
|
+
<xs:element name="active" minOccurs="0" maxOccurs="1">
|
47
|
+
<xs:complexType>
|
48
|
+
<xs:simpleContent>
|
49
|
+
<xs:restriction base="Boolean">
|
50
|
+
</xs:restriction>
|
51
|
+
</xs:simpleContent>
|
52
|
+
</xs:complexType>
|
53
|
+
</xs:element>
|
44
54
|
XML
|
45
55
|
end
|
46
56
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: schematic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Case Commons, LLC
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-30 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|