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, #hash, #initialize, #map, #type_cast_for_schema

Constructor Details

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

Instance Method Details

#serialize(value) ⇒ Object


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

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

#typeObject


4
5
6
# File 'activemodel/lib/active_model/type/immutable_string.rb', line 4

def type
  :string
end