Sha256: d3ff94b065e5981fa3e923f6e8e52112e67c08e60811a1fd2d929294b53f9f2e

Contents?: true

Size: 961 Bytes

Versions: 27

Compression:

Stored size: 961 Bytes

Contents

module Foobara
  module TypeDeclarations
    module Handlers
      class ExtendRegisteredModelTypeDeclaration < ExtendRegisteredTypeDeclaration
        class NormalizeMutableAttributesDesugarizer < TypeDeclarations::Desugarizer
          def applicable?(value)
            if value.is_a?(::Hash) && value.key?(:mutable) && value.key?(:type)
              mutable = value[:mutable]

              return false if [true, false].include?(mutable)

              if !mutable.is_a?(::Array) || (mutable.is_a?(::Array) && mutable.any? { |k| !k.is_a?(::Symbol) })
                type = type_for_declaration(value[:type])
                type.extends?(BuiltinTypes[:model])
              end
            end
          end

          def desugarize(rawish_type_declaration)
            rawish_type_declaration.merge(
              mutable: Util.array(rawish_type_declaration[:mutable]).map!(&:to_sym)
            )
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
foobara-0.0.7 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
foobara-0.0.6 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
foobara-0.0.5 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
foobara-0.0.4 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
foobara-0.0.3 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
foobara-0.0.2 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb
foobara-0.0.1 projects/model/src/extensions/type_declarations/handlers/extend_registered_model_type_declaration/normalize_mutable_attributes_desugarizer.rb