Class: Decidim::Initiatives::DummyTimestamp

Inherits:
Object
  • Object
show all
Defined in:
decidim-initiatives/app/services/decidim/initiatives/dummy_timestamp.rb

Overview

Example of service to generate a timestamp for a document

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ DummyTimestamp

Public: Initializes the service. document - The document for which the timestamp is going to be generated signature_type


12
13
14
# File 'decidim-initiatives/app/services/decidim/initiatives/dummy_timestamp.rb', line 12

def initialize(args = {})
  @document = args.fetch(:document)
end

Instance Attribute Details

#documentObject

Returns the value of attribute document


7
8
9
# File 'decidim-initiatives/app/services/decidim/initiatives/dummy_timestamp.rb', line 7

def document
  @document
end

Instance Method Details

#timestampObject

Public: Timestamp generated from data


17
18
19
# File 'decidim-initiatives/app/services/decidim/initiatives/dummy_timestamp.rb', line 17

def timestamp
  @timestamp ||= Base64.encode64(OpenSSL::Digest.digest("SHA1", "#{@document}-#{Time.current}")).chop
end