Sha256: 76252da4ac8bd5d9bc50e04620abd307ecca683d138c9b484b178872cea2da4b
Contents?: true
Size: 774 Bytes
Versions: 1
Compression:
Stored size: 774 Bytes
Contents
module ApiValidator class Assertion attr_reader :value, :path, :type, :format def initialize(path, value, options = {}) @path, @value, @type, @format = path, value, options.delete(:type), options.delete(:format) end def to_hash(options = {}) _h = { :op => "test", :path => path, :value => stringified_value } _h.delete(:value) if type && value.nil? _h[:type] = "regexp" if Regexp === value _h[:type] = type if type _h[:format] = format if format _h end def stringified_value if Regexp === value regex = value.to_s. sub(%r|\(\?-mix:(.*)\)|) { $1 }. gsub("\\A", "^"). gsub("\\Z", "$") "/#{regex}/" else value end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api-validator-0.0.1 | lib/api-validator/assertion.rb |