Class: EasyKeyValue

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/easy_key_value/easy_key_value.rb

Class Method Summary collapse

Class Method Details

.add_key(object, key, value) ⇒ Object

Adds a key with a given value for a given object

Parameters:

  • object (ActiveRecord::Base)

    An Active Record instance

  • key (String)

    The key

  • value (String)

    The value of this key



13
14
15
16
17
18
19
20
# File 'lib/easy_key_value/easy_key_value.rb', line 13

def self.add_key(object, key, value)
  ekv = EasyKeyValue.new
  ekv.ekv_id = object.id
  ekv.ekv_type = object.class.to_s
  ekv.key = key
  ekv.value = value
  ekv.save
end