Sha256: e4efa2512eada4eda1b8d624f45767bc7d170d7dc80dd33956cd0494eba9d48d

Contents?: true

Size: 314 Bytes

Versions: 2

Compression:

Stored size: 314 Bytes

Contents

# frozen_string_literal: true

module ActiveFields
  module Casters
    class EnumCaster < BaseCaster
      def serialize(value)
        cast(value)
      end

      def deserialize(value)
        cast(value)
      end

      private

      def cast(value)
        value&.to_s.presence
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_fields-1.1.0 lib/active_fields/casters/enum_caster.rb
active_fields-1.0.0 lib/active_fields/casters/enum_caster.rb