supressing nil attributes on objects
This commit is contained in:
@ -35,10 +35,11 @@ module Sof
|
||||
return SimpleNode.new( object.name )
|
||||
end
|
||||
head = object.class.name + "("
|
||||
atts = attributes_for(object).inject({}) do |hash , a|
|
||||
atts = {}
|
||||
attributes_for(object).each() do |a|
|
||||
val = get_value(object , a)
|
||||
hash[a] = to_sof_node(val , level + 1)
|
||||
hash
|
||||
next if val.nil?
|
||||
atts[a] = to_sof_node(val , level + 1)
|
||||
end
|
||||
immediate , extended = atts.partition {|a,val| val.is_a?(SimpleNode) }
|
||||
head += immediate.collect {|a,val| "#{a.to_sof()} => #{val.data}"}.join(", ") + ")"
|
||||
|
@ -83,5 +83,11 @@ module Virtual
|
||||
end
|
||||
attr_reader :to , :from
|
||||
end
|
||||
|
||||
|
||||
class ObjectGet < Instruction
|
||||
def initialize name
|
||||
@name = name.to_sym
|
||||
end
|
||||
attr_reader :name
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user