Class: Hanami::Model::Plugins::Timestamps::InputWithTimestamp Private

Inherits:
WrappingInput
  • Object
show all
Defined in:
lib/hanami/model/plugins/timestamps.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Takes the input and applies the timestamp transformation. This is an “abstract class”, please look at the subclasses for specific behaviors.

Since:

  • 0.7.0

Direct Known Subclasses

InputWithUpdateTimestamp

Constant Summary collapse

TIMESTAMPS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Conventional timestamp names

Since:

  • 0.7.0

%i[created_at updated_at].freeze

Instance Method Summary collapse

Constructor Details

#initialize(relation, input) ⇒ InputWithTimestamp

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of InputWithTimestamp.

Since:

  • 0.7.0



26
27
28
29
# File 'lib/hanami/model/plugins/timestamps.rb', line 26

def initialize(relation, input)
  super
  @timestamps = relation.columns & TIMESTAMPS
end

Instance Method Details

#[](value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Processes the input

Since:

  • 0.7.0



35
36
37
38
39
# File 'lib/hanami/model/plugins/timestamps.rb', line 35

def [](value)
  return @input[value] unless timestamps?

  _touch(@input[value], Time.now)
end