lib/roxml/definition.rb in roxml-3.1.2 vs lib/roxml/definition.rb in roxml-3.1.3

- old
+ new

@@ -13,11 +13,11 @@ module ROXML class ContradictoryNamespaces < StandardError end class Definition # :nodoc: - attr_reader :name, :type, :wrapper, :hash, :blocks, :accessor, :to_xml, :attr_name, :namespace + attr_reader :name, :sought_type, :wrapper, :hash, :blocks, :accessor, :to_xml, :attr_name, :namespace bool_attr_reader :name_explicit, :array, :cdata, :required, :frozen def initialize(sym, opts = {}, &block) opts.assert_valid_keys(:from, :in, :as, :namespace, :else, :required, :frozen, :cdata, :to_xml) @@ -41,26 +41,26 @@ end @array = opts[:as].is_a?(Array) @blocks = collect_blocks(block, opts[:as]) - @type = extract_type(opts[:as]) - if @type.respond_to?(:roxml_tag_name) - opts[:from] ||= @type.roxml_tag_name + @sought_type = extract_type(opts[:as]) + if @sought_type.respond_to?(:roxml_tag_name) + opts[:from] ||= @sought_type.roxml_tag_name end if opts[:from] == :content opts[:from] = '.' elsif opts[:from] == :name opts[:from] = '*' elsif opts[:from] == :attr - @type = :attr + @sought_type = :attr opts[:from] = nil elsif opts[:from] == :name opts[:from] = '*' elsif opts[:from].to_s.starts_with?('@') - @type = :attr + @sought_type = :attr opts[:from].sub!('@', '') end @attr_name = accessor.to_s.chomp('?') @name = (opts[:from] || @attr_name).to_s @@ -81,17 +81,17 @@ :"#{attr_name}=" end def hash if hash? - @type.wrapper ||= name - @type + @sought_type.wrapper ||= name + @sought_type end end def hash? - @type.is_a?(HashDefinition) + @sought_type.is_a?(HashDefinition) end def name? @name == '*' end @@ -107,14 +107,14 @@ end @default.duplicable? ? @default.dup : @default end def to_ref(inst) - case type + case sought_type when :attr then XMLAttributeRef when :text then XMLTextRef when HashDefinition then XMLHashRef - when Symbol then raise ArgumentError, "Invalid type argument #{type}" + when Symbol then raise ArgumentError, "Invalid type argument #{sought_type}" else XMLObjectRef end.new(self, inst) end private