Skip to content

Commit

Permalink
Merge pull request #3657 from samvera/rename_objects
Browse files Browse the repository at this point in the history
rename objects to child_objects
  • Loading branch information
elrayle authored Mar 18, 2019
2 parents 36cf01c + c9b9869 commit bc59aea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions lib/wings/hydra/pcdm/models/concerns/pcdm_valkyrie_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,22 @@ def parent_collection_ids(valkyrie: false)
# Gives the subset of #members that are PCDM objects
# @return [Enumerable<ActiveFedora::Base> | Enumerable<Valkyrie::Resource>] an enumerable over the members
# that are PCDM objects
def objects(valkyrie: false)
def child_objects(valkyrie: false)
af_objects = Wings::ActiveFedoraConverter.new(resource: self).convert.objects
return af_objects unless valkyrie
af_objects.map(&:valkyrie_resource)
end
alias members objects
alias ordered_members objects
alias objects child_objects
alias members child_objects
alias ordered_members child_objects

##
# Gives a subset of #member_ids, where all elements are PCDM objects.
# @return [Enumerable<String> | Enumerable<Valkyrie::ID] the object ids
def object_ids(valkyrie: false)
objects(valkyrie: valkyrie).map(&:id)
def child_object_ids(valkyrie: false)
child_objects(valkyrie: valkyrie).map(&:id)
end
alias object_ids child_object_ids
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
# end
end

describe '#objects' do
describe '#child_objects' do
let(:pcdm_object) { collection1 }

before do
Expand All @@ -153,23 +153,23 @@

context 'when valkyrie resources requested' do
it 'returns works only as valkyrie resources through pcdm_valkyrie_behavior' do
resources = resource.objects(valkyrie: true)
resources = resource.child_objects(valkyrie: true)
expect(resources.size).to eq 2
expect(resources.first.pcdm_object?).to be true
expect(resources.map(&:id)).to match_valkyrie_ids_with_active_fedora_ids([work1.id, work2.id])
end
end
context 'when active fedora objects requested' do
it 'returns works only as fedora objects through pcdm_valkyrie_behavior' do
af_objects = resource.objects(valkyrie: false)
af_objects = resource.child_objects(valkyrie: false)
expect(af_objects.size).to eq 2
expect(af_objects.first.pcdm_object?).to be true
expect(af_objects.map(&:id)).to match_array [work1.id, work2.id]
end
end
context 'when return type is not specified' do
it 'returns works only as fedora objects through pcdm_valkyrie_behavior' do
af_objects = resource.objects
af_objects = resource.child_objects
expect(af_objects.size).to eq 2
expect(af_objects.first.pcdm_object?).to be true
expect(af_objects.map(&:id)).to match_array [work1.id, work2.id]
Expand All @@ -187,21 +187,21 @@

context 'when valkyrie resources requested' do
it 'returns ids of works only as valkyrie resources through pcdm_valkyrie_behavior' do
resource_ids = resource.object_ids(valkyrie: true)
resource_ids = resource.child_object_ids(valkyrie: true)
expect(resource_ids.size).to eq 2
expect(resource_ids).to match_valkyrie_ids_with_active_fedora_ids([work1.id, work2.id])
end
end
context 'when active fedora objects requested' do
it 'returns ids of works only as fedora objects through pcdm_valkyrie_behavior' do
af_object_ids = resource.object_ids(valkyrie: false)
af_object_ids = resource.child_object_ids(valkyrie: false)
expect(af_object_ids.size).to eq 2
expect(af_object_ids.to_a).to match_array [work1.id, work2.id]
end
end
context 'when return type is not specified' do
it 'returns ids of works only as fedora objects through pcdm_valkyrie_behavior' do
af_object_ids = resource.object_ids
af_object_ids = resource.child_object_ids
expect(af_object_ids.size).to eq 2
expect(af_object_ids.to_a).to match_array [work1.id, work2.id]
end
Expand Down

0 comments on commit bc59aea

Please sign in to comment.