Should Property override to_s to return the value as a string? #3

jamsden opened this Issue May 30, 2012 · 0 comments


None yet
1 participant

jamsden commented May 30, 2012

eyal.age now returns a Property, not a value as it did in the old API. You need to use eyal.age.first, or eyal.age.only to get the value. And this will fail if eyal.age is nil.

Should Property override to_s so that eyal.age prints the value of the property instead of its URI? This might be a convenience in string expressions and would provide some backward compatibility with the old API and examples.

The key is that all properties can be multi-valued. It seems that eyal.age should never return nil, it should return at least []. But currently it is possible that a property that has no value will be nil. In the context of multi-valued properties, is there a semantic difference between nil and []. The difference could be whether these is a schema defining the domain of the property or not.

def to_s
values = to_a
if values == nil then
elsif values.size == 1 then
"[#{values.collect{|obj| obj.inspect}.join(", ")}]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment