Class: ServiceTrack::NuevaRotura

Inherits:
Object
  • Object
show all
Defined in:
lib/service_track/nueva_rotura.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ NuevaRotura

Returns a new instance of NuevaRotura.



3
4
5
6
7
# File 'lib/service_track/nueva_rotura.rb', line 3

def initialize(opts)
  opts.each_pair { |k, v| instance_variable_set("@#{k}", v) }

  @cantidad = 1 # de momento ?
end

Instance Method Details

#create_roturasObject



15
16
17
18
19
# File 'lib/service_track/nueva_rotura.rb', line 15

def create_roturas
  @elementos_y_prd_tracks.each do |eypt|
    RoturaVidrio.create(item_medida_id: @item_medida.id, elemento_id: eypt[:elemento].id, observacion: @motivo_rotura, motivo_id: @motivo_id, momento_id: @momento_id, puesto_control_id: @puesto_rotura_vidrio.id, user_id: @current_user.try(:id))
  end
end

#saveObject



9
10
11
12
13
# File 'lib/service_track/nueva_rotura.rb', line 9

def save
  ActiveRecord::Base.transaction do
    create_roturas
  end
end