blob: ec3f861abd6c43491b54ad29e3fcd07c2c13e754 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
module ActiveRecord
module Type
module Casting
def cast(value)
typecaster.type_cast(value)
end
def precast(value)
value
end
def boolean(value)
cast(value).present?
end
# Attributes::Typecasting stores appendable? types (e.g. serialized Arrays) when typecasting reads.
def appendable?
false
end
end
class Object
include Casting
attr_reader :name, :options
attr_reader :typecaster
def initialize(typecaster = nil, options = {})
@typecaster, @options = typecaster, options
end
end
end
end
|