Skip to content

Commit ad375dc

Browse files
committed
Extracted all attributes out to their own file
There were a number of attributes that were written in the same file. Separating them out should help further refactoring and make things more consistent
1 parent 8e5b3ef commit ad375dc

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
77

88
### Changed
99
- All limit classes are now stored in their own files in 'json-schema/attributes/limits'
10+
- All attribute classes are now stored in their own files in 'json-schema/attributes'
1011

1112
### Fixed
1213
- Corrected the draft6 schema id to `http://json-schema.org/draft/schema#`

lib/json-schema/attributes/dependencies.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,5 @@ def self.accept_value?(value)
3434
value.is_a?(String) || value.is_a?(Array) || value.is_a?(Hash)
3535
end
3636
end
37-
38-
class DependenciesV4Attribute < DependenciesAttribute
39-
def self.accept_value?(value)
40-
value.is_a?(Array) || value.is_a?(Hash)
41-
end
42-
end
4337
end
4438
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'json-schema/attributes/dependencies'
2+
3+
module JSON
4+
class Schema
5+
class DependenciesV4Attribute < DependenciesAttribute
6+
def self.accept_value?(value)
7+
value.is_a?(Array) || value.is_a?(Hash)
8+
end
9+
end
10+
end
11+
end

lib/json-schema/attributes/properties.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,5 @@ def self.validate(current_schema, data, fragments, processor, validator, options
6262
end
6363
end
6464
end
65-
66-
class PropertiesV4Attribute < PropertiesAttribute
67-
# draft4 relies on its own RequiredAttribute validation at a higher level, rather than
68-
# as an attribute of individual properties.
69-
def self.required?(schema, options)
70-
options[:strict] == true
71-
end
72-
end
7365
end
7466
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
require 'json-schema/attributes/properties'
2+
3+
module JSON
4+
class Schema
5+
class PropertiesV4Attribute < PropertiesAttribute
6+
# draft4 relies on its own RequiredAttribute validation at a higher level, rather than
7+
# as an attribute of individual properties.
8+
def self.required?(schema, options)
9+
options[:strict] == true
10+
end
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)