Class: Decidim::Initiatives::DummyTimestamp
- Inherits:
-
Object
- Object
- Decidim::Initiatives::DummyTimestamp
- Defined in:
- app/services/decidim/initiatives/dummy_timestamp.rb
Overview
Example of service to generate a timestamp for a document
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ DummyTimestamp
constructor
Public: Initializes the service.
-
#timestamp ⇒ Object
Public: Timestamp generated from data.
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 'app/services/decidim/initiatives/dummy_timestamp.rb', line 12 def initialize(args = {}) @document = args.fetch(:document) end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
7 8 9 |
# File 'app/services/decidim/initiatives/dummy_timestamp.rb', line 7 def document @document end |
Instance Method Details
#timestamp ⇒ Object
Public: Timestamp generated from data
17 18 19 |
# File 'app/services/decidim/initiatives/dummy_timestamp.rb', line 17 def @timestamp ||= Base64.encode64(OpenSSL::Digest.digest("SHA1", "#{@document}-#{Time.current}")).chop end |