Module: SerializedAttributes
- Defined in:
- lib/serialized_attributes/serialized_attributes.rb
Defined Under Namespace
Modules: Boolean, ClassMethods, InstanceMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/serialized_attributes/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) ⇒ Object
85
86
87
88
89
90
91
92
|
# File 'lib/serialized_attributes/serialized_attributes.rb', line 85
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
|
Instance Method Details
#to_variable(sym) ⇒ Object
81
82
83
|
# File 'lib/serialized_attributes/serialized_attributes.rb', line 81
def to_variable(sym)
"@#{sym.to_s}".to_sym
end
|