class Lacerda::ObjectDescription
Attributes
name[R]
schema[R]
service[R]
Public Class Methods
new(defined_in_service, scoped_name, schema)
click to toggle source
# File lib/lacerda/object_description.rb, line 23 def initialize(defined_in_service, scoped_name, schema) @defined_in_service = defined_in_service @scoped_name = scoped_name @name = remove_service_from_scoped_name(scoped_name) @schema = schema.with_indifferent_access @schema['$schema'] ||= 'http://json-schema.org/draft-04/schema#' end
Public Instance Methods
validate_data(data)
click to toggle source
# File lib/lacerda/object_description.rb, line 35 def validate_data(data) JSON::Validator.validate!(@schema, data) rescue JSON::Schema::ValidationError false end
validate_data!(data)
click to toggle source
# File lib/lacerda/object_description.rb, line 31 def validate_data!(data) JSON::Validator.validate!(@schema, data) end
Private Instance Methods
remove_service_from_scoped_name(n)
click to toggle source
# File lib/lacerda/object_description.rb, line 43 def remove_service_from_scoped_name(n) i = n.index(Lacerda::SCOPE_SEPARATOR) return n unless i n[i+Lacerda::SCOPE_SEPARATOR.length..-1] end