Module: OM::XML::Validation::ClassMethods
- Defined in:
- lib/om/xml/validation.rb
Overview
Class Methods – These methods will be available on classes that include this Module
Instance Attribute Summary collapse
-
#schema_file ⇒ Object
Retrieve the schema file for this class If the schema file is not already set, it will be loaded from the schema url provided in the root_property configuration for the class.
-
#schema_url ⇒ Object
Returns the value of attribute schema_url.
Instance Method Summary collapse
-
#schema ⇒ Object
Retrieve the Nokogiri Schema for this class.
-
#validate(doc) ⇒ Object
Validate the given document against the Schema provided by the root_property for this class.
Instance Attribute Details
#schema_file ⇒ Object
Retrieve the schema file for this class If the schema file is not already set, it will be loaded from the schema url provided in the root_property configuration for the class
28 29 30 |
# File 'lib/om/xml/validation.rb', line 28 def schema_file @schema_file ||= file_from_url(schema_url) end |
#schema_url ⇒ Object
Returns the value of attribute schema_url.
7 8 9 |
# File 'lib/om/xml/validation.rb', line 7 def schema_url @schema_url end |
Instance Method Details
#schema ⇒ Object
Retrieve the Nokogiri Schema for this class
22 23 24 |
# File 'lib/om/xml/validation.rb', line 22 def schema @schema ||= Nokogiri::XML::Schema(schema_file.read) end |
#validate(doc) ⇒ Object
Validate the given document against the Schema provided by the root_property for this class
15 16 17 18 19 |
# File 'lib/om/xml/validation.rb', line 15 def validate(doc) schema.validate(doc).each do |error| puts error. end end |