lib/treequel/schema.rb in treequel-1.2.2 vs lib/treequel/schema.rb in treequel-1.3.0pre384
- old
+ new
@@ -207,21 +207,25 @@
def operational_attribute_types
return self.attribute_types.values.find_all {|attrtype| attrtype.operational? }.uniq
end
+ ### Return the schema as a human-readable english string.
+ def to_s
+ parts = [ "Schema:" ]
+ parts << self.ivar_descriptions.collect {|desc| ' ' + desc }
+ return parts.join( $/ )
+ end
+
+
### Return a human-readable representation of the object suitable for debugging.
### @return [String]
def inspect
- ivar_descs = self.instance_variables.sort.collect do |ivar|
- len = self.instance_variable_get( ivar ).length
- "%d %s" % [ len, ivar.to_s.gsub(/_/, ' ')[1..-1] ]
- end
return %{#<%s:0x%0x %s>} % [
self.class.name,
self.object_id / 2,
- ivar_descs.join(', '),
+ self.ivar_descriptions.join( ', ' ),
]
end
#########
@@ -305,8 +309,18 @@
table
end
end
+
+ ### Return descriptions of the schema's artifacts.
+ ### @return [Array<String>] the descriptions of the schema's artifacts, and how many of each
+ ### it has.
+ def ivar_descriptions
+ self.instance_variables.sort.collect do |ivar|
+ len = self.instance_variable_get( ivar ).length
+ "%d %s" % [ len, ivar.to_s.gsub(/_/, ' ')[1..-1] ]
+ end
+ end
end # class Treequel::Schema