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


143
144
145
# File 'lib/rom/plugins/command/timestamps.rb', line 143

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


121
122
123
# File 'lib/rom/plugins/command/timestamps.rb', line 121

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