Class: EasyJSONMatcher::SchemaGenerator
- Inherits:
-
Object
- Object
- EasyJSONMatcher::SchemaGenerator
- Defined in:
- lib/easy_json_matcher/schema_generator.rb
Instance Attribute Summary collapse
-
#att_glob_opts ⇒ Object
readonly
Returns the value of attribute att_glob_opts.
-
#glob_opts ⇒ Object
readonly
Returns the value of attribute glob_opts.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #create_node(opts:) ⇒ Object
-
#generate_node ⇒ Object
Methods for generating the schema #########################.
- #generate_schema ⇒ Object
-
#initialize(opts: [], global_opts: [], **args, &block) ⇒ SchemaGenerator
constructor
A new instance of SchemaGenerator.
- #new_node_generator(opts:, globals:) ⇒ Object
- #register(as:) ⇒ Object
Constructor Details
#initialize(opts: [], global_opts: [], **args, &block) ⇒ SchemaGenerator
Returns a new instance of SchemaGenerator.
15 16 17 18 19 20 21 22 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 15 def initialize(opts: [], global_opts: [], **args, &block) super(**args) @glob_opts = global_opts @att_glob_opts = glob_opts.dup @att_glob_opts.delete(:strict) @node = new_node_generator(opts: opts, globals: global_opts) node.instance_eval &block if block_given? end |
Instance Attribute Details
#att_glob_opts ⇒ Object (readonly)
Returns the value of attribute att_glob_opts.
13 14 15 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 13 def att_glob_opts @att_glob_opts end |
#glob_opts ⇒ Object (readonly)
Returns the value of attribute glob_opts.
13 14 15 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 13 def glob_opts @glob_opts end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
13 14 15 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 13 def node @node end |
Instance Method Details
#create_node(opts:) ⇒ Object
24 25 26 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 24 def create_node(opts:) node.new(opts: opts) end |
#generate_node ⇒ Object
Methods for generating the schema #########################
30 31 32 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 30 def generate_node node.generate_node end |
#generate_schema ⇒ Object
34 35 36 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 34 def generate_schema validator.new validate_with: generate_node end |
#new_node_generator(opts:, globals:) ⇒ Object
43 44 45 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 43 def new_node_generator(opts:, globals:) node_generator.new(opts: opts, global_opts: globals) end |
#register(as:) ⇒ Object
38 39 40 41 |
# File 'lib/easy_json_matcher/schema_generator.rb', line 38 def register(as:) schema_library.add_schema(name: as, schema: generate_node) generate_schema end |