lib/rbbt/util/tsv/accessor.rb in rbbt-util-3.1.0 vs lib/rbbt/util/tsv/accessor.rb in rbbt-util-3.2.0
- old
+ new
@@ -87,10 +87,11 @@
def key_field
return nil if @key_field.nil?
k = @key_field.dup
k.extend Field
+ k.namespace = namespace unless namespace.nil?
k
end
def fields
return nil if @fields.nil?
@@ -132,10 +133,15 @@
def identify_field(field)
TSV.identify_field(key_field, fields, field)
end
+ def key_field=(new_key_field)
+ @key_field = new_key_field
+ @data.key_field = new_key_field if @data.respond_to? :key_field= and @data.write?
+ end
+
def fields=(new_fields)
new_fields.collect! do |field|
if Field === field
if field !~ /:/ and field.namespace != nil and field.namespace != namespace
field.namespace + ":" + field.to_s
@@ -148,15 +154,10 @@
end if Array === new_fields
@fields = new_fields
@data.fields = new_fields if @data.respond_to? :fields= and @data.write?
end
- def old_fields=(new_fields)
- @fields = new_fields
- @data.fields = new_fields if @data.respond_to? :fields=
- end
-
def keys
@data.keys
end
def values
@@ -181,16 +182,17 @@
end
end
# Read
+ attr_accessor :unnamed
def follow(value)
return nil if value.nil?
if String === value && value =~ /__Ref:(.*)/
return self[$1]
else
- if Array === value and fields
+ if Array === value and not unnamed
value = NamedArray.name value, fields
end
value
end
end