Sha256: 2973e82fa55de92db8c2cfe20b8bf9e4160996e5b7f425bc6949f562040a99c0
Contents?: true
Size: 577 Bytes
Versions: 3
Compression:
Stored size: 577 Bytes
Contents
require 'active_record' class EasyKeyValue < ActiveRecord::Base # The key must be unique for a given instance validates :key, :uniqueness => {:scope => [:ekv_id, :ekv_type]} # Adds a key with a given value for a given object # # @param [ActiveRecord::Base] object An Active Record instance # @param [String] key The key # @param [String] value The value of this key 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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
easy_key_value-0.1.2 | lib/easy_key_value/easy_key_value.rb |
easy_key_value-0.1.1 | lib/easy_key_value/easy_key_value.rb |
easy_key_value-0.1.0 | lib/easy_key_value/easy_key_value.rb |