Class: Superstudio::SqlJsonBuilder
- Inherits:
-
Object
- Object
- Superstudio::SqlJsonBuilder
- Includes:
- SchemaInternalDefiner, SchemaInterpreter, SchemaReader
- Defined in:
- lib/superstudio.rb
Instance Attribute Summary collapse
-
#array_paths ⇒ Object
Returns the value of attribute array_paths.
-
#human_to_internal ⇒ Object
Returns the value of attribute human_to_internal.
-
#json_nodes ⇒ Object
Returns the value of attribute json_nodes.
-
#json_result ⇒ Object
Returns the value of attribute json_result.
-
#required_columns ⇒ Object
Returns the value of attribute required_columns.
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#sql_columns ⇒ Object
Returns the value of attribute sql_columns.
-
#template_bodies ⇒ Object
Returns the value of attribute template_bodies.
-
#template_types ⇒ Object
Returns the value of attribute template_types.
Instance Method Summary collapse
-
#initialize(query, file_name = nil) ⇒ SqlJsonBuilder
constructor
A new instance of SqlJsonBuilder.
Methods included from SchemaInternalDefiner
#add_to_describe_arrays, #convert_fork_paths_to_base_route_numbers, #generate_internal_fork_number_of_type, #handle_array_stop_path, #set_human_to_internal_mappings
Methods included from SchemaInterpreter
#create_template, #interpret_json_schema
Methods included from SchemaReader
#parse_json_schema, #read_schema, #replace_reference_keys, #schema_maps_directory, #schemas_directory
Constructor Details
#initialize(query, file_name = nil) ⇒ SqlJsonBuilder
Returns a new instance of SqlJsonBuilder.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/superstudio.rb', line 14 def initialize(query, file_name = nil) file_class_name = self.class.name file_class_name.slice!("Mapper") file_name ||= file_class_name.underscore << ".json.schema" @schema = read_schema(file_name) @sql_columns, @row_being_used = [], [] @json_result = "" @json_nodes, @required_columns = {}, {} , , , , @do_not_hash, , , @column_names = [], [], [], [], [], [], [], [] @type_2_paths, @type_3_paths, @type_4_paths, @type_5_paths = [], [], [], [] @type_2_indicator_names, @type_4_indicator_names = ["root"], [] @unique_threes_paths = [] json_schema_interpretation = interpret_json_schema(@schema) if query.present? result_set = get_sql_results(query) set_human_to_internal_mappings(json_schema_interpretation) assemble_json(result_set) else create_template(json_schema_interpretation) end end |
Instance Attribute Details
#array_paths ⇒ Object
Returns the value of attribute array_paths.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def array_paths @array_paths end |
#human_to_internal ⇒ Object
Returns the value of attribute human_to_internal.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def human_to_internal @human_to_internal end |
#json_nodes ⇒ Object
Returns the value of attribute json_nodes.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def json_nodes @json_nodes end |
#json_result ⇒ Object
Returns the value of attribute json_result.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def json_result @json_result end |
#required_columns ⇒ Object
Returns the value of attribute required_columns.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def required_columns @required_columns end |
#schema ⇒ Object
Returns the value of attribute schema.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def schema @schema end |
#sql_columns ⇒ Object
Returns the value of attribute sql_columns.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def sql_columns @sql_columns end |
#template_bodies ⇒ Object
Returns the value of attribute template_bodies.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def template_bodies @template_bodies end |
#template_types ⇒ Object
Returns the value of attribute template_types.
12 13 14 |
# File 'lib/superstudio.rb', line 12 def template_types @template_types end |