lib/eav_hashes/eav_hash.rb
def update_or_create_entry(key, value)
        raise "Key must be a string or a symbol!" unless key.is_a?(String) or key.is_a?(Symbol)
        load_entries_if_needed

        @changes_made = true
        @owner.updated_at = Time.now

        if @entries[key]
          @entries[key].value = value
        else
          new_entry = @options[:entry_class].new
          set_entry_owner(new_entry)
          new_entry.key = key
          new_entry.value = value

          @entries[key] = new_entry

          value
        end
      end
# Creates a new EavHash. You should really let eav_hash_for do this for you...
# @param [ActiveRecord::Base] owner the Model which will own this hash
# @param [Hash] options the options hash which eav_hash generated
Creates a new EavHash. You should really let eav_hash_for do this for you
Creates a new EavHash . You should really let eav_hash_for do this for you
def update_or_create_entry(key, value)
        raise "Key must be a string or a symbol!" unless key.is_a?(String) or key.is_a?(Symbol)
        load_entries_if_needed
        @changes_made = true
        @owner.updated_at = Time.now
        if @entries[key]
          @entries[key].value = value
        else
          new_entry = @options[:entry_class].new
          set_entry_owner(new_entry)
          new_entry.key = key
          new_entry.value = value
          @entries[key] = new_entry
          value
        end
      end
def update_or_create_entry ( key , value ) raise "Key must be a string or a symbol!" unless key . is_a? ( String ) or key . is_a? ( Symbol ) load_entries_if_needed @changes_made = true @owner . updated_at = Time . now if @entries [ key ] @entries [ key ] . value = value else new_entry = @options [ :entry_class ] . new set_entry_owner ( new_entry ) new_entry . key = key new_entry . value = value @entries [ key ] = new_entry value end end
Creates a new EavHash.
Creates a new EavHash .
key
value
options the options hash which eav_hash generated
options the options hash which eav_hash generated