Module: Hydra::Works::CollectionBehavior

Extended by:
ActiveSupport::Concern
Included in:
Collection
Defined in:
lib/hydra/works/models/concerns/collection_behavior.rb

Overview

8) Hydra::Works::Collection can have descriptive metadata

9) Hydra::Works::Collection can have access metadata

Instance Method Summary collapse

Instance Method Details

#child_collection_idsObject



43
44
45
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 43

def child_collection_ids
  collection_ids + member_collection_ids
end

#child_collectionsObject



39
40
41
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 39

def child_collections
  collections + member_collections
end

#child_work_idsObject



51
52
53
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 51

def child_work_ids
  work_ids + member_work_ids
end

#child_worksObject



47
48
49
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 47

def child_works
  works + member_works
end

#collection?Boolean

Returns whether this instance is a Hydra::Works Collection.

Returns:

  • (Boolean)

    whether this instance is a Hydra::Works Collection.



92
93
94
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 92

def collection?
  true
end

#file_set?Boolean

Returns whether this instance is a Hydra::Works::FileSet.

Returns:

  • (Boolean)

    whether this instance is a Hydra::Works::FileSet.



102
103
104
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 102

def file_set?
  false
end

#member_collection_idsObject



77
78
79
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 77

def member_collection_ids
  member_collections.map(&:id)
end

#member_collectionsObject



71
72
73
74
75
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 71

def member_collections
  return [] if id.nil?
  member_objects = ActiveFedora::Base.where('member_of_collection_ids_ssim' => id)
  member_objects.select(&:collection?).to_a
end

#member_work_idsObject



87
88
89
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 87

def member_work_ids
  member_works.map(&:id)
end

#member_worksObject



81
82
83
84
85
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 81

def member_works
  return [] if id.nil?
  member_objects = ActiveFedora::Base.where('member_of_collection_ids_ssim' => id)
  member_objects.select(&:work?).to_a
end

#ordered_work_idsObject



59
60
61
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 59

def ordered_work_ids
  ordered_works.map(&:id)
end

#ordered_worksObject



55
56
57
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 55

def ordered_works
  ordered_members.to_a.select(&:work?)
end

#parent_collection_idsObject



35
36
37
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 35

def parent_collection_ids
  in_collection_ids + member_of_collection_ids
end

#parent_collectionsObject



31
32
33
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 31

def parent_collections
  in_collections + member_of_collections
end

#work?Boolean

Returns whether this instance is a Hydra::Works Generic Work.

Returns:

  • (Boolean)

    whether this instance is a Hydra::Works Generic Work.



97
98
99
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 97

def work?
  false
end

#work_idsObject



67
68
69
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 67

def work_ids
  works.map(&:id)
end

#worksObject



63
64
65
# File 'lib/hydra/works/models/concerns/collection_behavior.rb', line 63

def works
  members.select(&:work?)
end