class Blufin::YmlJavaModelWriter
Constants
- PACKAGE
- PLACEHOLDER_CLASS_PROPERTIES
- PLACEHOLDER_CONSTRUCTOR_CONTENT
- PLACEHOLDER_CONTENT
- PLACEHOLDER_DELETE
- PLACEHOLDER_GET
- PLACEHOLDER_GET_CALLS
- PLACEHOLDER_IMPORT
- PLACEHOLDER_OBJECT
- PLACEHOLDER_OBJECT_LOWER
- PLACEHOLDER_PATCH
- PLACEHOLDER_POST
- PLACEHOLDER_POST_ID_CAPTURE
- PLACEHOLDER_POST_INITIAL
- PLACEHOLDER_PUT
- PLACEHOLDER_PUT_INITIAL
- PLACEHOLDER_PUT_ORPHAN_REMOVAL
- PLACEHOLDER_RESOURCE_DEPTHS
- PLACEHOLDER_SCHEMA_UPPERCASE
- PLACEHOLDER_SITE_DOMAIN
- PLACEHOLDER_SITE_NAME
- SERVICE
Public Class Methods
new(site, schema_data, schema_resources)
click to toggle source
@return void
# File lib/core/yml_writers/yml_java_model_writer.rb, line 30 def initialize(site, schema_data, schema_resources) @schema_data = schema_data @schema_resources = schema_resources raise RuntimeError, 'Could not find valid @schema_data.' if @schema_data.nil? || !@schema_data.is_a?(Hash) raise RuntimeError, 'Could not find valid @schema_resources.' if @schema_resources.nil? || !@schema_resources.is_a?(Hash) @site = Blufin::SiteResolver::validate_site(site) @site_name = Blufin::SiteResolver::get_site_name(@site) @site_domain = Blufin::SiteResolver::get_site_domain(@site) @site_domain_gsub = @site_domain.strip == '' ? '' : "#{@site_domain}" @site_location = "#{Blufin::SiteResolver::get_site_location(@site)}/" # Wipe out all previous files. Blufin::YmlSchemaValidator::VALID_SCHEMAS_GENERATE.each do |schema| path_to_wipe_out = "#{get_java_path(@site, schema, SERVICE, PACKAGE)}" if Blufin::Files::path_exists(path_to_wipe_out) if Blufin::Files::get_files_in_dir(path_to_wipe_out).any? Blufin::Terminal::command('rm *', path_to_wipe_out, false, false) end end end @template = <<TEMPLATE package #{PLACEHOLDER_SITE_DOMAIN}.#{PLACEHOLDER_SITE_NAME}.api.#{PACKAGE}; import org.blufin.api.base.AbstractResource; import org.blufin.base.enums.SchemaType; import org.blufin.api.base.AbstractModel; import org.blufin.base.exceptions.BlufinServerException; import org.blufin.base.exceptions.BlufinClientException; import org.blufin.base.exceptions.BlufinNotImplementedException; import org.blufin.base.helper.IdSet; import lombok.Getter; import org.blufin.api.base.model.GetModel; import org.blufin.api.base.model.PostModel; import org.blufin.api.base.model.PutModel; import org.blufin.api.base.model.PatchModel; import org.blufin.api.base.model.DeleteModel; import org.blufin.base.helper.Pair; import org.blufin.core.server.db.ConnectionFactory; import org.blufin.sdk.response.ApiResponsePagination; import org.blufin.api.helper.IdExtractor; import org.blufin.base.helper.IdSet; import org.blufin.sdk.rest.GetRequest; import org.blufin.sdk.rest.PostRequest; import org.blufin.sdk.rest.PutRequest; import org.blufin.sdk.rest.PatchRequest; import org.blufin.sdk.rest.DeleteRequest; import org.blufin.sdk.response.ApiResponse; import org.blufin.sdk.response.ResourceModificationResponse; import org.blufin.sdk.base.PersistentDto; import #{PLACEHOLDER_SITE_DOMAIN}.#{PLACEHOLDER_SITE_NAME}.api.#{Blufin::SiteServices::PACKAGE_AUTO_GENERATED}.dao.#{PLACEHOLDER_OBJECT}Dao; import #{PLACEHOLDER_SITE_DOMAIN}.#{PLACEHOLDER_SITE_NAME}.sdk.dto.#{PLACEHOLDER_OBJECT}; import java.sql.Connection; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import org.apache.commons.dbutils.DbUtils; import java.util.HashSet; import java.util.Set; import java.util.List; import java.sql.Connection; import java.sql.SQLException; import org.springframework.stereotype.Service; import java.util.Map;#{PLACEHOLDER_IMPORT} @Service public final class #{PLACEHOLDER_OBJECT}Model extends AbstractModel<#{PLACEHOLDER_OBJECT}> { @Getter private static final #{PLACEHOLDER_OBJECT}Model instance = new #{PLACEHOLDER_OBJECT}Model(); #{PLACEHOLDER_CLASS_PROPERTIES} private #{PLACEHOLDER_OBJECT}Model() { #{PLACEHOLDER_CONSTRUCTOR_CONTENT} } #{PLACEHOLDER_CONTENT}} TEMPLATE @template_get = <<TEMPLATE @Override protected ApiResponse<#{PLACEHOLDER_OBJECT}> get(Connection connection, GetRequest request) throws BlufinServerException { Pair<ApiResponsePagination, List<#{PLACEHOLDER_OBJECT}>> #{PLACEHOLDER_OBJECT_LOWER}Response = #{PLACEHOLDER_OBJECT_LOWER}Dao.get(connection, request); #{PLACEHOLDER_GET} return buildApiResponse(#{PLACEHOLDER_OBJECT_LOWER}Response.getKey(), #{PLACEHOLDER_OBJECT_LOWER}Response.getValue()); } TEMPLATE @template_post = <<TEMPLATE @Override protected void post(Connection connection, PostRequest<#{PLACEHOLDER_OBJECT}> request) throws BlufinServerException { #{PLACEHOLDER_POST_ID_CAPTURE}for (#{PLACEHOLDER_OBJECT} #{PLACEHOLDER_OBJECT_LOWER} : request.getPayload()) { #{PLACEHOLDER_POST_INITIAL}#{PLACEHOLDER_POST} } } TEMPLATE @template_put = <<TEMPLATE @Override protected void put(Connection connection, PutRequest<#{PLACEHOLDER_OBJECT}> request) throws BlufinServerException { #{PLACEHOLDER_PUT_ORPHAN_REMOVAL}for (#{PLACEHOLDER_OBJECT} #{PLACEHOLDER_OBJECT_LOWER} : request.getPayload()) { #{PLACEHOLDER_PUT_INITIAL}#{PLACEHOLDER_PUT} } } TEMPLATE @template_patch = <<TEMPLATE @Override protected void patch(Connection connection, PatchRequest request) throws BlufinServerException { #{PLACEHOLDER_PATCH} } TEMPLATE @template_delete = <<TEMPLATE @Override protected void delete(Connection connection, DeleteRequest request) throws BlufinServerException { #{PLACEHOLDER_DELETE} } TEMPLATE @template_get_blank = <<TEMPLATE @Override protected ApiResponse<#{PLACEHOLDER_OBJECT}> get(Connection connection, GetRequest request) throws BlufinServerException { throw new BlufinNotImplementedException(); } TEMPLATE @template_post_blank = <<TEMPLATE @Override protected void post(Connection connection, PostRequest<#{PLACEHOLDER_OBJECT}> request) throws BlufinServerException { throw new BlufinNotImplementedException(); } TEMPLATE @template_put_blank = <<TEMPLATE @Override protected void put(Connection connection, PutRequest<#{PLACEHOLDER_OBJECT}> request) throws BlufinServerException { throw new BlufinNotImplementedException(); } TEMPLATE @template_patch_blank = <<TEMPLATE @Override protected void patch(Connection connection, PatchRequest request) throws BlufinServerException { throw new BlufinNotImplementedException(); } TEMPLATE @template_delete_blank = <<TEMPLATE @Override protected void delete(Connection connection, DeleteRequest request) throws BlufinServerException { throw new BlufinNotImplementedException(); } TEMPLATE end
Public Instance Methods
write()
click to toggle source
@return void
# File lib/core/yml_writers/yml_java_model_writer.rb, line 212 def write @schema_data.each do |schema, schema_data| schema_data.keys.each do |table| object = Blufin::Strings::snake_case_to_camel_case(table) object_lower = Blufin::Strings::snake_case_to_camel_case_lower(table) resource_data = @schema_resources["#{schema}.#{table}"] @has_get = YmlCommon::has_http_method(Blufin::YmlConfigValidator::GET, resource_data, Blufin::YmlSchemaValidator::CONFIG_INTERNAL) @has_post = YmlCommon::has_http_method(Blufin::YmlConfigValidator::POST, resource_data, Blufin::YmlSchemaValidator::CONFIG_INTERNAL) @has_put = YmlCommon::has_http_method(Blufin::YmlConfigValidator::PUT, resource_data, Blufin::YmlSchemaValidator::CONFIG_INTERNAL) @has_patch = YmlCommon::has_http_method(Blufin::YmlConfigValidator::PATCH, resource_data, Blufin::YmlSchemaValidator::CONFIG_INTERNAL) @has_delete = YmlCommon::has_http_method(Blufin::YmlConfigValidator::DELETE, resource_data, Blufin::YmlSchemaValidator::CONFIG_INTERNAL) # Skip if this resource has no HTTP Methods. next unless Blufin::YmlCommon::has_at_least_one_http_method(resource_data, Blufin::YmlSchemaValidator::CONFIG_INTERNAL) @import_statements = [] @daos = [table] @contents_get = [] @contents_get_calls = '' @contents_post = [] @contents_put = [] @contents_patch = [] @contents_delete = [] contents = @template contents_inner = '' contents_inner += @has_get ? @template_get : @template_get_blank contents_inner += @has_post ? @template_post : @template_post_blank contents_inner += @has_put ? @template_put : @template_put_blank contents_inner += @has_patch ? @template_patch : @template_patch_blank contents_inner += @has_delete ? @template_delete : @template_delete_blank # # TODO - REMOVE (Once POST/PUT/DELETE fully working) # if "#{schema}.#{table}" == 'mock.mock_nested_multiple' || "#{schema}.#{table}" == 'app.root_multiple' # # # TODO - REMOVE (Once POST/PUT/DELETE fully working) # puts "\x1B[38;5;198m#{schema}.#{table}\x1B[0m" # puts resource_data.to_yaml @contents_patch << " #{PLACEHOLDER_OBJECT_LOWER}Dao.patch(connection, request.getPayLoad());" if @has_patch @contents_delete << " #{PLACEHOLDER_OBJECT_LOWER}Dao.delete(connection, request.getIds());" if @has_delete @has_children = false @parent = resource_data[:parent] @child_type = Blufin::YmlCommon::extract_child_type_from_schema_data(@schema_data, schema, table) @child_type_java = Blufin::YmlCommon::extract_child_type_from_schema_data_for_java(@schema_data, schema, table) if !resource_data[:dependents].nil? && resource_data[:dependents].any? @objects = {} @has_children = true resource_data[:dependents].each do |dependent| dependent_data = @schema_resources["#{schema}.#{dependent}"] depth = dependent_data[:depth] - @schema_resources["#{schema}.#{table}"][:depth] parent_object = dependent_data[:tree][dependent_data[:tree].length - 2] dependent_data[:depth_relative] = depth @objects[parent_object] = [] unless @objects[parent_object].is_a?(Array) @objects[parent_object] << dependent_data end if @has_get @contents_get << '' @contents_get << " if (#{PLACEHOLDER_OBJECT_LOWER}Response.getValue().size() > 0) {" @contents_get << '' @contents_get << " List<Integer> #{PLACEHOLDER_OBJECT_LOWER}Ids = IdExtractor.extractIds(#{PLACEHOLDER_OBJECT_LOWER}Response.getValue());" @contents_get << '' @contents_get << PLACEHOLDER_GET_CALLS @contents_get << '' @contents_get << ' DbUtils.closeQuietly(connection);' @contents_get << '' @contents_get << " for (#{PLACEHOLDER_OBJECT} #{PLACEHOLDER_OBJECT_LOWER} : #{PLACEHOLDER_OBJECT_LOWER}Response.getValue()) {" loop_tree(table) @contents_get << ' }' @contents_get << ' }' @contents_get << '' end # Add trailing new line(s) for code-formatting purposes. @contents_post[@contents_post.length - 1] += "\n" if @contents_post.any? && @has_post if @contents_put.any? && @has_put @contents_put.unshift('') @contents_put[@contents_put.length - 1] += "\n" end end # end # TODO - REMOVE post_id_capture = '' if @child_type == Blufin::YmlSchemaValidator::RESOURCE_TYPE_OBJECT post_initial = " int #{object_lower}Id = #{object_lower}Dao.post(connection, #{object_lower});\n\n request.addIdToResponse(#{object_lower}Id);\n" put_initial = " putObjectElement(connection, #{PLACEHOLDER_OBJECT_LOWER}, #{PLACEHOLDER_OBJECT_LOWER}.getParentId(), #{PLACEHOLDER_OBJECT_LOWER}Dao);\n\n request.addIdToResponse(#{PLACEHOLDER_OBJECT_LOWER}.getId());\n" elsif @child_type == Blufin::YmlSchemaValidator::RESOURCE_TYPE_OBJECT_LIST post_id_capture = "request.addParentDataToResponse(request.getPayload(), \"#{table}\", \"#{@parent}_id\");\n\n " post_initial = " int #{object_lower}Id = #{object_lower}Dao.post(connection, #{object_lower});\n" put_initial = " #{PLACEHOLDER_OBJECT_LOWER}.setId(putListElement(connection, #{PLACEHOLDER_OBJECT_LOWER}, #{PLACEHOLDER_OBJECT_LOWER}Dao));\n\n request.addIdToResponse(#{PLACEHOLDER_OBJECT_LOWER}.getId());\n" else post_initial = " int #{object_lower}Id = #{object_lower}Dao.post(connection, #{object_lower});\n\n request.addIdToResponse(#{object_lower}Id);\n" put_initial = " putObjectElement(connection, #{PLACEHOLDER_OBJECT_LOWER}, #{PLACEHOLDER_OBJECT_LOWER}Dao);\n\n request.addIdToResponse(#{PLACEHOLDER_OBJECT_LOWER}.getId());\n" end put_orphan_removal = @child_type_java.nil? || @child_type != Blufin::YmlSchemaValidator::RESOURCE_TYPE_OBJECT_LIST ? '' : "removeOrphans(connection, request.getPayload(), #{object_lower}Dao);\n\n " contents_inner = contents_inner.gsub(PLACEHOLDER_GET, Blufin::YmlCommon::convert_line_array_to_string(@contents_get)) contents_inner = contents_inner.gsub(PLACEHOLDER_POST_ID_CAPTURE, post_id_capture) contents_inner = contents_inner.gsub(PLACEHOLDER_POST_INITIAL, post_initial) contents_inner = contents_inner.gsub(PLACEHOLDER_POST, Blufin::YmlCommon::convert_line_array_to_string(@contents_post)) contents_inner = contents_inner.gsub(PLACEHOLDER_PUT, Blufin::YmlCommon::convert_line_array_to_string(@contents_put)) contents_inner = contents_inner.gsub(PLACEHOLDER_PUT_INITIAL, put_initial) contents_inner = contents_inner.gsub(PLACEHOLDER_PUT_ORPHAN_REMOVAL, put_orphan_removal) contents_inner = contents_inner.gsub(PLACEHOLDER_PATCH, Blufin::YmlCommon::convert_line_array_to_string(@contents_patch)) contents_inner = contents_inner.gsub(PLACEHOLDER_DELETE, Blufin::YmlCommon::convert_line_array_to_string(@contents_delete)) @import_statements.sort! @import_statements.uniq! contents = contents.gsub(PLACEHOLDER_CONTENT, contents_inner.to_s) contents = contents.gsub(PLACEHOLDER_CLASS_PROPERTIES, Blufin::YmlCommon::convert_line_array_to_string(get_class_properties)) contents = contents.gsub(PLACEHOLDER_CONSTRUCTOR_CONTENT, Blufin::YmlCommon::convert_line_array_to_string(get_constructor_content)) contents = contents.gsub(PLACEHOLDER_GET_CALLS, @contents_get_calls) contents = contents.gsub(PLACEHOLDER_IMPORT, @import_statements.any? ? "\n#{@import_statements.join("\n")}" : '') contents = contents.gsub(PLACEHOLDER_SITE_NAME, @site_name.gsub('-', '.')) contents = contents.gsub(PLACEHOLDER_SITE_DOMAIN, @site_domain_gsub) contents = contents.gsub(PLACEHOLDER_SCHEMA, schema) contents = contents.gsub(PLACEHOLDER_SCHEMA_UPPERCASE, schema.upcase) contents = contents.gsub(PLACEHOLDER_OBJECT, object) contents = contents.gsub(PLACEHOLDER_OBJECT_LOWER, object_lower) # Hacky-fix for test classes. DO NOT remove this or Java won't compile. contents = contents.gsub('SchemaType.MOCK', 'null') if schema == Blufin::YmlSchemaValidator::MOCK write_file_java("#{get_java_path(@site, schema, SERVICE, PACKAGE)}/#{object}Model.java", Blufin::YmlCommon::convert_string_to_line_array(contents), schema == Blufin::YmlSchemaValidator::MOCK) end end end
Private Instance Methods
get_class_properties()
click to toggle source
# File lib/core/yml_writers/yml_java_model_writer.rb, line 496 def get_class_properties content = [] @daos.each { |dao| content << " private final #{Blufin::Strings::snake_case_to_camel_case(dao)}Dao #{Blufin::Strings::snake_case_to_camel_case_lower(dao)}Dao;" } content end
get_constructor_content()
click to toggle source
# File lib/core/yml_writers/yml_java_model_writer.rb, line 502 def get_constructor_content content = [] @daos.each { |dao| content << " this.#{Blufin::Strings::snake_case_to_camel_case_lower(dao)}Dao = #{Blufin::Strings::snake_case_to_camel_case(dao)}Dao.getInstance();" } content end
loop_tree(parent)
click to toggle source
# File lib/core/yml_writers/yml_java_model_writer.rb, line 365 def loop_tree(parent) if @objects.has_key?(parent) @objects[parent].each_with_index do |object, idx| obj_schema = object[:schema] obj_table = object[:table] obj_type = object[:type] # obj_tree = object[:tree] # TODO - REMOVE ONCE DONE (IF NOT NEEDED) obj_depth = object[:depth_relative] obj_cc = Blufin::Strings::snake_case_to_camel_case(obj_table) obj_ccl = Blufin::Strings::snake_case_to_camel_case_lower(obj_table) # parent_cc = Blufin::Strings::snake_case_to_camel_case(parent) # TODO - REMOVE ONCE DONE (IF NOT NEEDED) parent_ccl = Blufin::Strings::snake_case_to_camel_case_lower(parent) closing_get = [] closing_post = [] closing_put = [] closing_delete = [] previous_was_list = @schema_resources["#{obj_schema}.#{parent}"][:type] == Blufin::YmlSchemaValidator::RESOURCE_TYPE_OBJECT_LIST has_children = @objects.has_key?(obj_table) a = "#{@child_type == Blufin::YmlSchemaValidator::RESOURCE_TYPE_OBJECT_LIST ? ' ' : ' '}#{' ' * obj_depth}" a = previous_was_list ? "#{a} " : a b = "#{@child_type == Blufin::YmlSchemaValidator::RESOURCE_TYPE_OBJECT_LIST ? ' ' : ' '}#{' ' * obj_depth}" b = previous_was_list ? "#{b} " : b @daos << obj_table unless @daos.include?(obj_table) @import_statements << "import #{PLACEHOLDER_SITE_DOMAIN}.#{PLACEHOLDER_SITE_NAME}.sdk.dto.#{obj_cc};" @import_statements << "import #{PLACEHOLDER_SITE_DOMAIN}.#{PLACEHOLDER_SITE_NAME}.api.#{Blufin::SiteServices::PACKAGE_AUTO_GENERATED}.dao.#{obj_cc}Dao;" map_ids_method = "IdExtractor.extractIds#{previous_was_list ? 'FromList' : ''}" map_ids_string = obj_depth == 1 ? "#{PLACEHOLDER_OBJECT_LOWER}Ids" : "#{map_ids_method}(#{parent_ccl}Result)" case obj_type when Blufin::ScannerJavaEmbeddedObjects::OBJECT if @has_get @contents_get_calls << " Map<Integer, #{obj_cc}> #{obj_ccl}Result = #{obj_ccl}Dao.getObject(connection, \"#{parent}_id\", #{map_ids_string});\n" @contents_get << '' @contents_get << "#{a}#{obj_cc} #{obj_ccl} = #{obj_ccl}Result.get(#{parent_ccl}.getId());" @contents_get << '' @contents_get << "#{a}if (#{obj_ccl} != null) {" @contents_get << '' @contents_get << " #{a}#{parent_ccl}.set#{obj_cc}(#{obj_ccl});" closing_get << "#{a}}" end if @has_post @contents_post << '' @contents_post << "#{b}if (#{parent_ccl}.get#{obj_cc}() != null) {" @contents_post << '' @contents_post << " #{b}#{obj_cc} #{obj_ccl} = #{parent_ccl}.get#{obj_cc}();" @contents_post << '' @contents_post << " #{b}#{has_children ? "int #{obj_ccl}Id = " : ''}#{obj_ccl}Dao.post(connection, #{obj_ccl}, #{parent_ccl}Id);" closing_post << "#{b}}" end if @has_put @contents_put << '' @contents_put << "#{b}if (#{parent_ccl}.get#{obj_cc}() != null) {" @contents_put << '' @contents_put << " #{b}#{obj_cc} #{obj_ccl} = #{parent_ccl}.get#{obj_cc}();" @contents_put << '' @contents_put << " #{b}putObjectElement(connection, #{obj_ccl}, #{parent_ccl}.getId(), #{obj_ccl}Dao);" closing_put << "#{b}}" end when Blufin::ScannerJavaEmbeddedObjects::OBJECT_LIST if @has_get @contents_get_calls << " Map<Integer, List<#{obj_cc}>> #{obj_ccl}Result = #{obj_ccl}Dao.getObjectList(connection, \"#{parent}_id\", #{map_ids_string});\n" @contents_get << '' @contents_get << "#{a}List<#{obj_cc}> #{obj_ccl}List = #{obj_ccl}Result.get(#{parent_ccl}.getId());" @contents_get << '' @contents_get << "#{a}if (#{obj_ccl}List != null && #{obj_ccl}List.size() > 0) {" @contents_get << '' @contents_get << " #{a}for (#{obj_cc} #{obj_ccl} : #{obj_ccl}List) {" @contents_get << '' @contents_get << " #{a}#{parent_ccl}.get#{obj_cc}List().add(#{obj_ccl});" closing_get << " #{a}}" closing_get << "#{a}}" end if @has_post @contents_post << '' @contents_post << "#{b}if (#{parent_ccl}.get#{obj_cc}List() != null && #{parent_ccl}.get#{obj_cc}List().size() > 0) {" @contents_post << '' @contents_post << " #{b}for (#{obj_cc} #{obj_ccl} : #{parent_ccl}.get#{obj_cc}List()) {" @contents_post << '' @contents_post << " #{b}#{has_children ? "int #{obj_ccl}Id = " : ''}#{obj_ccl}Dao.post(connection, #{obj_ccl}, #{parent_ccl}Id);" closing_post << " #{b}}" closing_post << "#{b}}" end if @has_put @contents_put << '' @contents_put << "#{b}removeOrphans(connection, #{parent_ccl}.get#{obj_cc}List(), #{parent_ccl}.getId(), #{obj_ccl}Dao);" @contents_put << '' @contents_put << "#{b}if (#{parent_ccl}.get#{obj_cc}List() != null && #{parent_ccl}.get#{obj_cc}List().size() > 0) {" @contents_put << '' @contents_put << " #{b}for (#{obj_cc} #{obj_ccl} : #{parent_ccl}.get#{obj_cc}List()) {" @contents_put << '' @contents_put << " #{b}#{obj_ccl}.setId(putListElement(connection, #{obj_ccl}, #{parent_ccl}.getId(), #{obj_ccl}Dao));" closing_put << " #{b}}" closing_put << "#{b}}" end when Blufin::ScannerJavaEmbeddedObjects::OBJECT_LINK # TODO - FINISH THIS else raise RuntimeError, "Unhandled object type: #{obj_type}" end loop_tree(obj_table) if @objects.has_key?(obj_table) closing_get.each { |x| @contents_get << x } if closing_get.any? && @has_get closing_post.each { |x| @contents_post << x } if closing_post.any? && @has_post closing_put.each { |x| @contents_put << x } if closing_put.any? && @has_put closing_delete.each { |x| @contents_delete << x } if closing_delete.any? && @has_delete end end end