Sha256: 48258ba14768303155e50e1e4468b8c1da771cfa7970691085481c98115c05fe
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
# # Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at) # require "active_record" module Toaster class KeyValuePair < ActiveRecord::Base self.inheritance_column = :type serialize :value, JSON def initialize(hash) if !hash[:type] type = IgnoreProperty.to_s end super(hash) @attributes_cache = {} if !@attributes_cache # fixes bug in active_record v4.1 end def self.get_as_hash(list) attrs = {} list.each do |a| attrs[a.key] = a.value end return attrs end def self.from_hash(hash, clazz=KeyValuePair) result = [] return result if !hash hash.each { |key,value| result << clazz.new( :key => key, :value => value ) } return result end def to_s return "#{self.class}(#{key}=#{value})" end def hash begin return id if id rescue end h = 0 h += key.hash rescue 0 h += value.hash rescue 0 h += type.hash rescue 0 h += data_type.hash rescue 0 return h end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cloud-toaster-1.1.5 | lib/toaster/model/key_value_pair.rb |
cloud-toaster-1.1.2 | lib/toaster/model/key_value_pair.rb |