Module: Hypercharge::Schema
- Defined in:
- lib/ruby/hypercharge/schema.rb,
lib/ruby/hypercharge/schema/version.rb
Defined Under Namespace
Modules: Fixture
Constant Summary collapse
- VERSION =
"1.24.5"
Class Method Summary collapse
-
.each ⇒ Object
yields with json schema files full path.
-
.schema_path_for(type) ⇒ String
returns the path for a JSON-Schema.
-
.validate(type, data) ⇒ Object
validates a hash with JSON-Schema.
Class Method Details
.each ⇒ Object
yields with json schema files full path. If you need the schema as hash, please feel free to IO.read() and JSON.parse().
25 26 27 28 29 |
# File 'lib/ruby/hypercharge/schema.rb', line 25 def self.each Dir[File.("../../../../json/*.json", __FILE__)].each do |path| yield path end end |
.schema_path_for(type) ⇒ String
returns the path for a JSON-Schema
19 20 21 |
# File 'lib/ruby/hypercharge/schema.rb', line 19 def self.schema_path_for(type) File.("../../../../json/#{type}.json", __FILE__) end |
.validate(type, data) ⇒ Object
validates a hash with JSON-Schema
12 13 14 |
# File 'lib/ruby/hypercharge/schema.rb', line 12 def self.validate(type, data) JSON::Validator.fully_validate(schema_path_for(type), data, :version => :draft3) end |