Sha256: 8bb2edf07b064eb93f68dfb06bf888f12d23206afb05bf2aa2c361e723c71035

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

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

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

            def schema(_)
              STACK
            end

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scaffold_parser-0.10.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/complex_type.rb
scaffold_parser-0.9.1 lib/scaffold_parser/scaffolders/xsd/parser/handlers/complex_type.rb
scaffold_parser-0.9.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/complex_type.rb
scaffold_parser-0.8.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/complex_type.rb
scaffold_parser-0.7.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/complex_type.rb