Class: JsonSchemaView::SchemaSet
- Inherits:
-
Object
- Object
- JsonSchemaView::SchemaSet
- Includes:
- ConstantSearchHelper
- Defined in:
- lib/json_schema_view/schema_set.rb,
lib/json_schema_view/schema_set/constant_search_helper.rb
Overview
Builder build components
Defined Under Namespace
Modules: ConstantSearchHelper
Instance Method Summary collapse
- #clear_export_path ⇒ void
- #export_json_schemas(print_logs: false) ⇒ void
- #export_path ⇒ String abstract
- #resource_classes_to_export ⇒ Array<Class<JsonSchemaDefinable>>
- #root_path ⇒ String abstract
Methods included from ConstantSearchHelper
#all_constants, #search_component_classes, #search_constants
Instance Method Details
#clear_export_path ⇒ void
This method returns an undefined value.
54 55 56 |
# File 'lib/json_schema_view/schema_set.rb', line 54 def clear_export_path FileUtils.rm_rf(export_path) if Dir.exist?(export_path) end |
#export_json_schemas(print_logs: false) ⇒ void
This method returns an undefined value.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/json_schema_view/schema_set.rb', line 33 def export_json_schemas(print_logs: false) puts "Exports resource classes in #{self.class.name}..." if print_logs export_pathname = Pathname.new(export_path) exports = resource_classes_to_export.map do |resource_class| destination = export_pathname.join("#{resource_class.name.demodulize}.json") klass = resource_class < JsonSchemaView::BaseComponent ? resource_class.props_class : resource_class [destination, resource_class, klass.to_json_schema] end clear_export_path exports.each do |destination, resource_class, json_schema| FileUtils.mkdir_p(destination.dirname) destination.write(json_schema) puts "#{resource_class.name} -> #{destination}" if print_logs end end |
#export_path ⇒ String
This method is abstract.
23 24 25 |
# File 'lib/json_schema_view/schema_set.rb', line 23 def export_path raise NotImplementedError end |
#resource_classes_to_export ⇒ Array<Class<JsonSchemaDefinable>>
28 29 30 |
# File 'lib/json_schema_view/schema_set.rb', line 28 def resource_classes_to_export [] end |
#root_path ⇒ String
This method is abstract.
17 18 19 |
# File 'lib/json_schema_view/schema_set.rb', line 17 def root_path raise NotImplementedError end |