module SerializedAttributes
Public Class Methods
included(base)
click to toggle source
# File lib/serialized_attributes.rb, line 2 def self.included(base) return if base.respond_to?(:serialized_attributes_definition) base.class_eval do class_inheritable_hash :serialized_attributes_definition write_inheritable_attribute(:serialized_attributes_definition, {}) cattr_accessor :serialized_attributes_column self.serialized_attributes_column = :serialized_attributes serialize serialized_attributes_column, Hash base.extend ClassMethods include InstanceMethods end end
type_to_sqltype(type)
click to toggle source
# File lib/serialized_attributes.rb, line 77 def self.type_to_sqltype(type) return type if type.is_a?(Symbol) { String => :string, Boolean => :boolean, Fixnum => :integer, Integer => :integer, BigDecimal => :decimal, Float => :float, Date => :date, Time => :time, DateTime => :time }[type] || type end
Public Instance Methods
to_variable(sym)
click to toggle source
# File lib/serialized_attributes.rb, line 73 def to_variable(sym) "@#{sym.to_s}".to_sym end