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

Defined in:
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



141
142
143
# File 'lib/rom/plugins/command/timestamps.rb', line 141

def datestamps(*names)
  config.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



119
120
121
# File 'lib/rom/plugins/command/timestamps.rb', line 119

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