Class: ActiveModel::Type::Binary
- Defined in:
- lib/active_model/type/binary.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Data
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
- #binary? ⇒ Boolean
- #cast(value) ⇒ Object
- #changed_in_place?(raw_old_value, value) ⇒ Boolean
- #serialize(value) ⇒ Object
- #type ⇒ Object
Methods inherited from Value
#==, #assert_valid_value, #changed?, #deserialize, #force_equality?, #hash, #immutable_value, #initialize, #map, #serializable?, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Constructor Details
This class inherits a constructor from ActiveModel::Type::Value
Instance Method Details
#cast(value) ⇒ Object
14 15 16 17 18 19 20 |
# File '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 '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 'lib/active_model/type/binary.rb', line 22 def serialize(value) return if value.nil? Data.new(super) end |
#type ⇒ Object
6 7 8 |
# File 'lib/active_model/type/binary.rb', line 6 def type :binary end |