Module: Hanami::Model::Plugins::Timestamps::ClassMethods Private

Defined in:
lib/hanami/model/plugins/timestamps.rb

Overview

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

Class interface

Since:

  • 0.7.0

Instance Method Summary collapse

Instance Method Details

#build(relation, options = {}) ⇒ 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.

Build an input processor according to the current command (create or update).

Since:

  • 0.7.0


96
97
98
99
100
101
102
103
104
105
# File 'lib/hanami/model/plugins/timestamps.rb', line 96

def build(relation, options = {})
  plugin = if self < ROM::Commands::Create
             InputWithCreateTimestamp
           else
             InputWithUpdateTimestamp
           end

  wrapped_input = plugin.new(relation, options.fetch(:input) { input })
  super(relation, options.merge(input: wrapped_input))
end