Module: ROM::Plugins::Command::Timestamps::ClassInterface

Defined in:
core/lib/rom/plugins/command/timestamps.rb

Instance Method Summary collapse

Instance Method Details

#datestamps(*names) ⇒ Object Also known as: datestamp

Set up attributes to datestamp when the command is called

Examples:

class CreateTask < ROM::Commands::Create[:sql]
  result :one
  use :timestamps
  datestamps :created_on, :updated_on
end

create_user = rom.command(:user).create.curry(name: 'Jane')

result = create_user.call
result[:created_at]  #=> Date.today

Parameters:

  • names (Array<Symbol>)

    A list of attribute names



139
140
141
# File 'core/lib/rom/plugins/command/timestamps.rb', line 139

def datestamps(*names)
  datestamp_columns datestamp_columns.merge(names)
end

#timestamps(*names) ⇒ Object Also known as: timestamp

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.

Set up attributes to timestamp when the command is called

Examples:

class CreateTask < ROM::Commands::Create[:sql]
  result :one
  use :timestamps
  timestamps :created_at, :updated_at
end

create_user = rom.command(:user).create.curry(name: 'Jane')

result = create_user.call
result[:created_at]  #=> Time.now.utc

Parameters:

  • names (Array<Symbol>)

    A list of attribute names



117
118
119
# File 'core/lib/rom/plugins/command/timestamps.rb', line 117

def timestamps(*names)
  timestamp_columns timestamp_columns.merge(names)
end