Class: HecksPlugins::JSONValidator::SchemaParser
- Inherits:
-
Object
- Object
- HecksPlugins::JSONValidator::SchemaParser
- Defined in:
- lib/parsers/schema_parser.rb
Overview
Create a JSON Schema from an object
Constant Summary collapse
- JSON_TYPES =
%w{string number object array boolean null}
- HECKS_NUMBER_TYPES =
%w{integer currency}
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(domain_module:, object:) ⇒ SchemaParser
constructor
A new instance of SchemaParser.
Constructor Details
#initialize(domain_module:, object:) ⇒ SchemaParser
Returns a new instance of SchemaParser.
9 10 11 12 13 |
# File 'lib/parsers/schema_parser.rb', line 9 def initialize domain_module:, object: @domain_module = domain_module @object = object @properties = {} end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
5 6 7 |
# File 'lib/parsers/schema_parser.rb', line 5 def schema @schema end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 |
# File 'lib/parsers/schema_parser.rb', line 15 def call parse_required_fields object.attributes.each { |a| parse_property(a) } build_schema self end |