Sha256: 71c6435090f5a2ca5b7948c2d552ca084b1dff1ceb4d851bdce171f7a155aea7

Contents?: true

Size: 824 Bytes

Versions: 5

Compression:

Stored size: 824 Bytes

Contents

module AttributedObject
  module Coerce
    def self.included(descendant)
      super
      descendant.send(:extend, ClassExtension)
      descendant.send(:include, InstanceMethods)
    end

    module ClassExtension
      include AttributedObject::Base::ClassExtension

      def _attributed_object_check_type_supported!(type_info)
        AttributedObjectHelpers::TypeCoerce.check_type_supported!(type_info)
      end
    end

    module InstanceMethods
      include AttributedObject::Base::InstanceMethods

      def _attributed_object_on_init_attribute(type_info, value, name:, args:)
        return AttributedObjectHelpers::TypeCoerce.coerce(
          type_info,
          value,
          coerce_blanks_to_nil: self.class.attributed_object_options.fetch(:coerce_blanks_to_nil)
        )
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attributed_object-0.4.0 lib/attributed_object/coerce.rb
attributed_object-0.3.1 lib/attributed_object/coerce.rb
attributed_object-0.3 lib/attributed_object/coerce.rb
attributed_object-0.2.2 lib/attributed_object/coerce.rb
attributed_object-0.2.1 lib/attributed_object/coerce.rb