lib/immutabler/template/builder.rb in immutabler-0.2.6 vs lib/immutabler/template/builder.rb in immutabler-0.3.0

- old
+ new

@@ -22,24 +22,20 @@ name: model.name, base_class: model.base, base_immutable: model.base_immutable, builder_base_class: model.builder_base, props: build_props(model.props), - any_mappings: model.mappings.any?, - array_mappings: model.mappings.select(&:array?), - dict_mappings: build_dict_mappings(model.mappings), - custom_mappers: build_custom_mappers(model.mappings), - mappings: build_mappings(model.mappings) } end links = defs[:links] + module_links = defs[:module_links] enums = defs[:enums] FileUtils.mkdir_p(group.output_directory) - build_head(group_name, models, links, enums) + build_head(group_name, models, links, module_links, enums) build_body(group_name, models) end private @@ -47,52 +43,18 @@ props.map do |prop| Immutabler::TypeMapper.map(prop.type, prop.options).merge(name: prop.name) end end - def build_dict_mappings(mappings) - mappings.select(&:dict?).map do |mapping| - attributes = mapping.dict_mappings.map do |dict_mapping| - { - origin_name: dict_mapping[:origin_name], - destination_name: dict_mapping[:destination_name] - } - end - - { - name: mapping.destination_name, - attributes: attributes - } - end - end - - def build_mappings(mappings) - mappings.map do |mapping| - { - origin_name: mapping.origin_name, - destination_name: mapping.destination_name - } - end - end - - def build_custom_mappers(mappings) - mappings.select(&:custom?).map do |mapping| - { - origin_name: mapping.origin_name, - transformer_name: mapping.custom_transformer - } - end - end - def build_body(group_name, models) body_template = Immutabler::Template::BodyTemplate.new(group_name, models) body_content = body_template.render body_path = "#{group.output_directory}/#{group_name}.m" File.write(body_path, body_content) end - def build_head(group_name, models, links, enums) - header_template = Immutabler::Template::HeaderTemplate.new(models, links, enums) + def build_head(group_name, models, links, module_links, enums) + header_template = Immutabler::Template::HeaderTemplate.new(models, links, module_links, enums) header_content = header_template.render header_path = "#{group.output_directory}/#{group_name}.h" File.write(header_path, header_content) end end