Class: ActiveModel::Type::ImmutableString
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/immutable_string.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Value
Instance Method Summary collapse
-
#initialize(**args) ⇒ ImmutableString
constructor
A new instance of ImmutableString.
- #serialize(value) ⇒ Object
- #type ⇒ Object
Methods inherited from Value
#==, #assert_valid_value, #binary?, #cast, #changed?, #changed_in_place?, #deserialize, #force_equality?, #hash, #map, #serializable?, #type_cast_for_schema, #value_constructed_by_mass_assignment?
Constructor Details
#initialize(**args) ⇒ ImmutableString
Returns a new instance of ImmutableString.
6 7 8 9 10 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/immutable_string.rb', line 6 def initialize(**args) @true = -(args.delete(:true)&.to_s || "t") @false = -(args.delete(:false)&.to_s || "f") super end |
Instance Method Details
#serialize(value) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/immutable_string.rb', line 16 def serialize(value) case value when ::Numeric, ::Symbol, ActiveSupport::Duration then value.to_s when true then @true when false then @false else super end end |
#type ⇒ Object
12 13 14 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/type/immutable_string.rb', line 12 def type :string end |