Sha256: 25d08d9c086c5f693668cfd3b5a38b59719409c5e7fd2c9ccc25db174081cbe7

Contents?: true

Size: 874 Bytes

Versions: 1

Compression:

Stored size: 874 Bytes

Contents

module ScaffoldParser
  module Scaffolders
    class XSD
      class Parser
        module Handlers
          class Choice
            attr_accessor :elements

            def initialize(elements = [])
              @elements = [*elements]
            end

            def complex_type(source)
              if source.has_name?
                STACK.push Klass.new(source.name, elements)
              else
                ComplexType.new(elements)
              end
            end

            def sequence(_)
              flattened = elements.flat_map do |element|
                case element
                when Sequence, Choice, All
                  then element.elements
                else
                  element
                end
              end

              Sequence.new flattened
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scaffold_parser-0.6.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/choice.rb