class ScaffoldParser::Scaffolders::XSD::Parser::Handlers::ListMethod
Attributes
at[RW]
item_class[RW]
Public Class Methods
new(source) { |self| ... }
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 12 def initialize(source) @source = source @at = [[source.xmlns_prefix, "#{source.name}"].compact.join(':')] yield self if block_given? end
Public Instance Methods
all(_)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 66 def all(_) self end
choice(_)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 62 def choice(_) self end
complex_type(source)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 70 def complex_type(source) if source.has_name? STACK.push Klass.new(source, [self]) else self end end
element(source)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 78 def element(source) if source.has_name? to_proxy_list(source, source.name) end end
extension(source)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 84 def extension(source) Extension.new(self, source.attributes) end
method_body()
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 19 def method_body "array_of_at(#{item_class}, #{single_quote(at)})" end
name_with_prefix()
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 23 def name_with_prefix [source.xmlns_prefix, "#{source.name}"].compact.join(':') end
sequence(_)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 58 def sequence(_) self end
to_builder()
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 35 def to_builder f = StringIO.new f.puts "if data.key? :#{method_name}" if item_class == 'String' f.puts " data[:#{method_name}].map { |i| Ox::Element.new('#{at.first}') << i }.each { |i| root << i }" else f.puts " data[:#{method_name}].each { |i| root << #{item_class}.new('#{at.first}', i).builder }" end f.puts 'end' f.string.strip end
to_h_method()
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 27 def to_h_method if item_class == 'String' "hash[:#{method_name}] = #{method_name} if has? '#{name_with_prefix}'" else "hash[:#{method_name}] = #{method_name}.map(&:to_h) if has? '#{name_with_prefix}'" end end
to_proxy_list(source, path)
click to toggle source
# File lib/scaffold_parser/scaffolders/xsd/parser/handlers/list_method.rb, line 49 def to_proxy_list(source, path) ProxyListMethod.new(source) do |m| prefixed_path = [source.xmlns_prefix, "#{source.name}"].compact.join(':') m.at = [prefixed_path] + @at m.item_class = @item_class end end