Sha256: d488b4120e04ceeaddb268d476a895441426985e94d4f59d5bfeb34da61d64d3

Contents?: true

Size: 894 Bytes

Versions: 26

Compression:

Stored size: 894 Bytes

Contents

module Foobara
  module TypeDeclarations
    module Attributes
      class << self
        def merge(*type_declarations)
          element_type_declarations = {}
          required = []
          defaults = {}

          type_declarations.each do |declaration_data|
            element_type_declarations.merge!(declaration_data[:element_type_declarations])
            type_defaults = declaration_data[:defaults]
            type_required = declaration_data[:required]

            if type_defaults && !type_defaults.empty?
              defaults.merge!(type_defaults)
            end

            if type_required && !type_required.empty?
              required += type_required
            end
          end

          {
            type: "::attributes",
            element_type_declarations:,
            required:,
            defaults:
          }
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
foobara-0.0.26 projects/type_declarations/src/attributes.rb
foobara-0.0.25 projects/type_declarations/src/attributes.rb
foobara-0.0.24 projects/type_declarations/src/attributes.rb
foobara-0.0.23 projects/type_declarations/src/attributes.rb
foobara-0.0.22 projects/type_declarations/src/attributes.rb
foobara-0.0.21 projects/type_declarations/src/attributes.rb
foobara-0.0.20 projects/type_declarations/src/attributes.rb
foobara-0.0.19 projects/type_declarations/src/attributes.rb
foobara-0.0.18 projects/type_declarations/src/attributes.rb
foobara-0.0.17 projects/type_declarations/src/attributes.rb
foobara-0.0.16 projects/type_declarations/src/attributes.rb
foobara-0.0.15 projects/type_declarations/src/attributes.rb
foobara-0.0.14 projects/type_declarations/src/attributes.rb
foobara-0.0.13 projects/type_declarations/src/attributes.rb
foobara-0.0.12 projects/type_declarations/src/attributes.rb
foobara-0.0.11 projects/type_declarations/src/attributes.rb
foobara-0.0.10 projects/type_declarations/src/attributes.rb
foobara-0.0.9 projects/type_declarations/src/attributes.rb
foobara-0.0.8 projects/type_declarations/src/attributes.rb
foobara-0.0.7 projects/type_declarations/src/attributes.rb