Method: Moneta::Adapters::ActiveRecord#delete

Defined in:
lib/moneta/adapters/activerecord.rb

#delete(key, options = {}) ⇒ Object

Delete the key from the store and return the current value

Parameters:

  • key (Object)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :raw (Boolean)

    Raw access without value transformation (See Transformer)

  • :prefix (String)

    Prefix key (See Transformer)

  • Other (Object)

    options as defined by the adapters or middleware

Returns:

  • (Object)

    current value



113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/moneta/adapters/activerecord.rb', line 113

def delete(key, options = {})
  with_connection do |conn|
    conn.transaction do
      sel = arel_sel_key(key).project(table[config.value_column]).lock
      value = decode(conn, conn.select_value(sel))

      del = arel_del.where(table[config.key_column].eq(key))
      conn.delete(del)

      value
    end
  end
end