This PR adds #to_ary to ActiveHash::Relation, which returns a #duped array of the items of the relation. When upgrading to active_hash 3.0.0, the following line in a controller that used active_model_serializers to return a collection of items of an ActiveHash data store did not work anymore, because active_model_serializers uses #respond_to?(:to_ary) to determine if an object is a collection or not (ActiveRecord::Relation does respond to this method). After this PR, this should work again.
This PR adds
#to_ary
toActiveHash::Relation
, which returns a#dup
ed array of the items of the relation. When upgrading to active_hash 3.0.0, the following line in a controller that used active_model_serializers to return a collection of items of an ActiveHash data store did not work anymore, because active_model_serializers uses#respond_to?(:to_ary)
to determine if an object is a collection or not (ActiveRecord::Relation
does respond to this method). After this PR, this should work again.I put the spec for this new method into a new file
spec/active_hash/relation_spec.rb
, because it would not really belong to thebase_spec.rb
.