Sha256: 87112f719aedda2b858534aeb61596fb05487fe57013e62897f23144c1e9bcef

Contents?: true

Size: 703 Bytes

Versions: 27

Compression:

Stored size: 703 Bytes

Contents

require "document/attribute_initializer/base"
require "document/attribute_initializer/active_model"
require "document/attribute_initializer/enum"

module Document
  module AttributeInitializer
    def self.determine_initializer(klass, name, type, options)
      initializer_class = build_class(type)
      initializer_class.new(klass, name, type, options)
    end

    def self.build_class(type)
      case
      when type == Document::Enum
        AttributeInitializer::Enum
      when type && type.included_modules.include?(::ActiveModel::Model)
        AttributeInitializer::ActiveModel
      else
        AttributeInitializer::Base
      end
    end

    private_class_method :build_class
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
renalware-core-2.0.16 lib/document/attribute_initializer.rb
renalware-core-2.0.15 lib/document/attribute_initializer.rb
renalware-core-2.0.14 lib/document/attribute_initializer.rb
renalware-core-2.0.13 lib/document/attribute_initializer.rb
renalware-core-2.0.12 lib/document/attribute_initializer.rb
renalware-core-2.0.11 lib/document/attribute_initializer.rb
renalware-core-2.0.9 lib/document/attribute_initializer.rb
renalware-core-2.0.8 lib/document/attribute_initializer.rb
renalware-core-2.0.7 lib/document/attribute_initializer.rb
renalware-core-2.0.5 lib/document/attribute_initializer.rb
renalware-core-2.0.4 lib/document/attribute_initializer.rb
renalware-core-2.0.3 lib/document/attribute_initializer.rb
renalware-core-2.0.2 lib/document/attribute_initializer.rb
renalware-core-2.0.1 lib/document/attribute_initializer.rb
renalware-core-2.0.0 lib/document/attribute_initializer.rb
renalware-core-2.0.0.pre.rc13 lib/document/attribute_initializer.rb
renalware-core-2.0.0.pre.rc11 lib/document/attribute_initializer.rb
renalware-core-2.0.0.pre.rc10 lib/document/attribute_initializer.rb
renalware-core-2.0.0.pre.rc9 lib/document/attribute_initializer.rb
renalware-core-2.0.0.pre.rc8 lib/document/attribute_initializer.rb