Sha256: dcefcf646a96dfc437141e28b26ba57694eb0343946f0a6390ba9fb7933b9c47

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

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

            def initialize(elements = [])
              @elements = [*elements]
            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

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

              ComplexType.new elements
            end

            def group(source)
              STACK.push Module.new("Groups::#{source.name.camelize}", elements)
            end

            def choice(_)
              self
            end

            def extension(source)
              Extension.new elements, source.attributes
            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/sequence.rb