Class: Nfe::Helpers::Signer

Inherits:
Object
  • Object
show all
Defined in:
lib/nfe/helpers/signer.rb

Instance Method Summary collapse

Constructor Details

#initialize(certificate, private_key) ⇒ Signer

Returns a new instance of Signer.



4
5
6
7
# File 'lib/nfe/helpers/signer.rb', line 4

def initialize(certificate, private_key)
  @certificate = certificate
  @private_key = private_key
end

Instance Method Details

#execute(objeto, id) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/nfe/helpers/signer.rb', line 9

def execute(objeto, id)
  objeto.signature = Nfe::Models::Signature.new(id)
  document = Xmldsig::SignedDocument.new(objeto.to_xml)
  document.sign(@private_key, @certificate)
  objeto.signature.value = sign_value(document)
  objeto
end