Demo entry 2360779

assembly

   

Submitted by anonymous on Aug 14, 2015 at 14:35
Language: Ruby. Code size: 2.0 kB.

  def assemble_row(row)
    load_holder     = build_load_holder(row[:load_holder]) unless row[:load_holder].nil?
    cargo           = build_cargo(row[:cargo]) unless row[:cargo].nil?
    dangerous_goods = build_dangerous_goods(row[:dangerous_goods]) unless row[:dangerous_goods].nil?

    if is_duplicate_load_holder?(load_holder) || load_holder.nil? # dupe load_holder
      if is_duplicate_cargo?(cargo)                                 # dupe cargo
        unless dangerous_goods.blank?                                 # has_dg
          @dupe_cargo.dangerous_goods.push(*dangerous_goods)
          # dangerous_goods.each{|dg| dg.cargo = @dupe_cargo}           #(assign dg)
        end
      elsif !dangerous_goods.blank?                                 # new  cargo
        cargo = Cargo.new(load_description: 'dg') if cargo.nil?       # (init cargo)
        @dupe_load_holder.cargos << cargo
        cargo.dangerous_goods = dangerous_goods                       # (assign dg)
        # dangerous_goods.each{|dg| dg.cargo = cargo}
      end
                                                                #---------------------#
    else
      unless load_holder.nil?                                     # new load_holder
        unless cargo.nil?                                           # new cargo
          load_holder.cargos << cargo                                 # (assign cargo)
          # cargo.load_holder = load_holder
        end
        unless dangerous_goods.blank?                               # has_dg
          if cargo.nil?                                               # no cargo
            cargo = Cargo.new(load_description: 'dg')                   # (init cargo)
            load_holder.cargos << cargo
            # cargo.load_holder = load_holder
          end
          cargo.dangerous_goods = dangerous_goods                     # (asign dg)
          # dangerous_goods.each{|dg| dg.cargo = cargo}
        end
      end
      @load_holders << load_holder
    end
  end

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).