Class: ActiveModel::Type::Binary
- Inherits:
-
Value
show all
- Defined in:
- activemodel/lib/active_model/type/binary.rb
Overview
Defined Under Namespace
Classes: Data
Instance Attribute Summary
Attributes inherited from Value
#limit, #precision, #scale
Instance Method Summary
collapse
Methods inherited from Value
#==, #assert_valid_value, #changed?, #deserialize, #force_equality?, #hash, #initialize, #map, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Instance Method Details
10
11
12
|
# File 'activemodel/lib/active_model/type/binary.rb', line 10
def binary?
true
end
|
#cast(value) ⇒ Object
14
15
16
17
18
19
20
|
# File 'activemodel/lib/active_model/type/binary.rb', line 14
def cast(value)
if value.is_a?(Data)
value.to_s
else
super
end
end
|
#changed_in_place?(raw_old_value, value) ⇒ Boolean
27
28
29
30
|
# File 'activemodel/lib/active_model/type/binary.rb', line 27
def changed_in_place?(raw_old_value, value)
old_value = deserialize(raw_old_value)
old_value != value
end
|
#serialize(value) ⇒ Object
22
23
24
25
|
# File 'activemodel/lib/active_model/type/binary.rb', line 22
def serialize(value)
return if value.nil?
Data.new(super)
end
|
6
7
8
|
# File 'activemodel/lib/active_model/type/binary.rb', line 6
def type
:binary
end
|