Sha256: 07d805f19a9504721aeb43a953a439971c45159ad3058d94394b9cdb71984140
Contents?: true
Size: 1.68 KB
Versions: 4
Compression:
Stored size: 1.68 KB
Contents
module ScaffoldParser module Scaffolders class XSD class Parser module Handlers class SubmodelMethod include BaseMethod include Utils attr_accessor :submodel_class def initialize(source, submodel_class = nil) @source = source @submodel_class = submodel_class || source.type&.split(':')&.map(&:camelize)&.join('::') end def at if source.name [source.xmlns_prefix, "#{source.name}"].compact.join(':') elsif source.ref source.ref end end def method_body "submodel_at(#{submodel_class}, '#{at}')" end def name_with_prefix [source.xmlns_prefix, "#{method_name}"].compact.join(':') end def to_h_method "hash[:#{method_name}] = #{method_name}.to_h if has? '#{at}'" end def to_builder f = StringIO.new f.puts "if data.key? :#{method_name}" f.puts " root << #{submodel_class}.new('#{at}', data[:#{method_name}]).builder" f.puts 'end' f.string.strip end def sequence(_) Sequence.new self end def choice(_) Choice.new self end def all(_) All.new self end def schema(_) STACK end def to_at_method AtMethod.new(source) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems