Class: Hyrax::Transactions::Steps::SetModifiedDate

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/transactions/steps/set_modified_date.rb

Overview

A step that sets the modified date to now for an input resource or change_set

Since:

  • 2.4.0

Instance Method Summary collapse

Constructor Details

#initialize(time_service: Hyrax::TimeService) ⇒ SetModifiedDate

Returns a new instance of SetModifiedDate.

Parameters:

  • time_service (#time_in_utc) (defaults to: Hyrax::TimeService)

Since:

  • 2.4.0



15
16
17
# File 'lib/hyrax/transactions/steps/set_modified_date.rb', line 15

def initialize(time_service: Hyrax::TimeService)
  @time_service = time_service
end

Instance Method Details

#call(obj) ⇒ Dry::Monads::Result

Parameters:

  • obj (#date_modified=)

Returns:

  • (Dry::Monads::Result)

Since:

  • 2.4.0



23
24
25
26
27
28
29
30
# File 'lib/hyrax/transactions/steps/set_modified_date.rb', line 23

def call(obj)
  return Failure[:no_date_modified_attribute, obj] unless
    obj.respond_to?(:date_modified=)

  obj.date_modified = @time_service.time_in_utc

  Success(obj)
end