Sha256: d49cab9fe76d5c7624e92f574a1e9e2fec541c0f2c3cd8028ab7f70be42e0bb5

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

module ScaffoldParser
  module Scaffolders
    class XSD
      class Parser
        module Handlers
          class Blank
            def elements
              []
            end

            def element(source)
              if source.multiple?
                if elements.any?
                  new_class = STACK.push Klass.new(source.name, elements)

                  ListMethod.new(source) do |template|
                    template.item_class = new_class.name.classify
                  end
                else
                  ListMethod.new(source) do |template|
                    template.item_class = source.has_custom_type? ? source&.type&.classify : 'String'
                  end
                end
              elsif source.has_custom_type?
                SubmodelMethod.new(source)
              else
                if elements.any?
                  new_class = STACK.push Klass.new(source.name, elements)
                  SubmodelMethod.new(source, new_class.name.camelize)
                else
                  AtMethod.new(source)
                end
              end
            end

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

            def extension(source)
              if source.custom_extension?
                Extension.new(elements, source.attributes)
              else # basic xsd extension
                self
              end

            end

            def include(_)
              Include.new
            end

            def import(_)
              Import.new
            end

            def schema(_)
              STACK
            end

            def group(source)
              ModuleInclude.new(source.ref)
            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/blank.rb