Class: ActiveModel::Type::ImmutableString

Inherits:
Value show all
Defined in:
activemodel/lib/active_model/type/immutable_string.rb

Overview

:nodoc:

Direct Known Subclasses

String

Instance Attribute Summary

Attributes inherited from Value

#limit, #precision, #scale

Instance Method Summary collapse

Methods inherited from Value

#==, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #initialize, #map, #type_cast_for_schema, #value_constructed_by_mass_assignment?

Constructor Details

This class inherits a constructor from ActiveModel::Type::Value

Instance Method Details

#serialize(value) ⇒ Object



10
11
12
13
14
15
16
17
# File 'activemodel/lib/active_model/type/immutable_string.rb', line 10

def serialize(value)
  case value
  when ::Numeric, ::Symbol, ActiveSupport::Duration then value.to_s
  when true then "t"
  when false then "f"
  else super
  end
end

#typeObject



6
7
8
# File 'activemodel/lib/active_model/type/immutable_string.rb', line 6

def type
  :string
end