Can't Index Both AF::Base Objects AND Literals
This is a problem introduced by #830 that I didn't notice until I'd merged it. If you have something like this...
class GenericAsset < ActiveFedora::Base
property :set, :predicate => RDF::DC.title, :class_name => "Set"
end
and you do something like
g = GenericAsset.new
g.title = ["Test"]
g.save
it'll error with something like
Exception: NoMethodError: undefined method `uri' for "Test":String
--
0: /Users/terrellt/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/active-triples-0.7.1/lib/active_triples/relation.rb:20:in `map'
1: /Users/terrellt/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/active-triples-0.7.1/lib/active_triples/relation.rb:20:in `map'
2: /Users/terrellt/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/bundler/gems/active_fedora-1db3d1f986d5/lib/active_fedora/rdf/field_map.rb:78:in `find_values'
It's always been valid to store literals alongside URIs, and it'd just cast to the object if it could.
@awead Pinging you, since this was your PR.
I'd need to defer to @jcoyne on this one, as he and I worked on this refactor. I'm not sure what the value of specifying a string for your class is, as opposed to the class itself if it's supposed to be an instance of AF::Base.
I would change ResourceBuilder to:
class ResourceBuilder < Builder
def find_values
object.send(name).respond_to?(:uri)
object.send(name).map(&:uri)
else
Array(object.send(name))
end
end
end
@terrellt I can't reproduce this. See https://gist.github.com/awead/9b383247c425d3d73d1d
@terrellt can we close this?
@tpendragon closable?