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

Class Method Details

.eachObject

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.expand_path("../../../../json/*.json", __FILE__)].each do |path|
		yield path
	end
end

.schema_path_for(type) ⇒ String

returns the path for a JSON-Schema

Parameters:

  • type (Hypercharge::Payment::Type, Hypercharge::PaymentTransaction::Type)

    the type

Returns:

  • (String)

    path



19
20
21
# File 'lib/ruby/hypercharge/schema.rb', line 19

def self.schema_path_for(type)
	File.expand_path("../../../../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