Class: Jamef::Params

Inherits:
OpenStruct
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/jamef/params.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Params

validates :tiptra, :cnpjcpf, :munori, :estori, :segprod, :qtdvol, :peso, :valmer, :metro3, :cepdes, :filcot, presence: true

Raises:

  • (ArgumentError)


19
20
21
22
23
24
# File 'lib/jamef/params.rb', line 19

def initialize *args
  super
  
  raise ArgumentError, errors.full_messages.join("\n") unless self.valid?
  self
end

Instance Method Details

#delivery_hashObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/jamef/params.rb', line 44

def delivery_hash
  hash = {}
  hash.store(:tiptra, tiptra)
  hash.store(:munori, munori)
  hash.store(:estori, estori)
  hash.store(:cnpjcpf, cnpjcpf)
  hash.store(:segprod, segprod)
  hash.store(:cdatini, cdatini)
  hash.store(:chorini, chorini)
  hash.store(:cnpjdes, cnpjdes)
  hash.store(:cepdes, cepdes)
  hash
end

#freight_hashObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jamef/params.rb', line 26

def freight_hash
  hash = {}
  hash.store(:tiptra, tiptra)
  hash.store(:cnpjcpf, cnpjcpf)
  hash.store(:munori, munori)
  hash.store(:estori, estori)
  hash.store(:segprod, segprod)
  hash.store(:qtdvol, qtdvol)
  hash.store(:peso, peso)
  hash.store(:valmer, valmer)
  hash.store(:metro3, metro3)
  hash.store(:cnpjdes, cnpjdes)
  hash.store(:filcot, filcot)
  hash.store(:cepdes, cepdes)
  hash.store(:contrib, contrib) if contrib?
  hash
end