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

[: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



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

def initialize(relation, input)
  super
  columns     = relation.columns.sort
  @timestamps = (columns & TIMESTAMPS) == 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



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

def [](value)
  return value unless timestamps?
  _touch(@input[value], Time.now)
end