Module: Hydra::Works::WorkBehavior
- Extended by:
- ActiveSupport::Concern, Deprecation
- Included in:
- Work
- Defined in:
- lib/hydra/works/models/concerns/work_behavior.rb
Overview
This module provides all of the Behaviors of a Hydra::Works::Work
behavior:
1) Hydra::Works::Work can aggregate Hydra::Works::Work
2) Hydra::Works::Work can aggregate Hydra::Works::FileSet
3) Hydra::Works::Work can NOT aggregate Hydra::PCDM::Collection
4) Hydra::Works::Work can NOT aggregate Hydra::Works::Collection
5) Hydra::Works::Work can NOT aggregate Works::Object unless it is also a Hydra::Works::FileSet
6) Hydra::Works::Work can NOT contain PCDM::File
7) Hydra::Works::Work can NOT aggregate non-PCDM object
8) Hydra::Works::Work can NOT contain Hydra::Works::FileSet
9) Hydra::Works::Work can have descriptive metadata
10) Hydra::Works::Work can have access metadata
Instance Method Summary collapse
- #child_file_set_ids ⇒ Object
- #child_file_sets ⇒ Object
- #child_work_ids ⇒ Object
- #child_works ⇒ Object
-
#collection? ⇒ Boolean
Whether this instance is a Hydra::Works Collection.
-
#file_set? ⇒ Boolean
Whether this instance is a Hydra::Works::FileSet.
- #file_set_ids ⇒ Object
- #file_sets ⇒ Object
- #in_work_ids ⇒ Object
- #in_works ⇒ Object
- #member_of_work_ids ⇒ Object
- #member_of_works ⇒ Object
- #member_work_ids ⇒ Object
- #member_works ⇒ Object
- #ordered_file_set_ids ⇒ Object
- #ordered_file_sets ⇒ Object
- #ordered_work_ids ⇒ Object
- #ordered_works ⇒ Object
- #parent_collection_ids ⇒ Object
- #parent_collections ⇒ Object
- #parent_work_ids ⇒ Object
- #parent_works ⇒ Object
-
#work? ⇒ Boolean
Whether this instance is a Hydra::Works Generic Work.
- #work_ids ⇒ Object
- #works ⇒ Object
Instance Method Details
#child_file_set_ids ⇒ Object
60 61 62 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 60 def child_file_set_ids file_set_ids end |
#child_file_sets ⇒ Object
56 57 58 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 56 def child_file_sets file_sets end |
#child_work_ids ⇒ Object
52 53 54 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 52 def child_work_ids work_ids + member_work_ids end |
#child_works ⇒ Object
48 49 50 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 48 def child_works works + member_works end |
#collection? ⇒ Boolean
Returns whether this instance is a Hydra::Works Collection.
109 110 111 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 109 def collection? false end |
#file_set? ⇒ Boolean
Returns whether this instance is a Hydra::Works::FileSet.
119 120 121 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 119 def file_set? false end |
#file_set_ids ⇒ Object
94 95 96 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 94 def file_set_ids file_sets.map(&:id) end |
#file_sets ⇒ Object
90 91 92 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 90 def file_sets members.select(&:file_set?) end |
#in_work_ids ⇒ Object
127 128 129 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 127 def in_work_ids in_works.map(&:id) end |
#in_works ⇒ Object
123 124 125 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 123 def in_works ordered_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::WorkBehavior) }.to_a end |
#member_of_work_ids ⇒ Object
135 136 137 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 135 def member_of_work_ids member_of_works.map(&:id) end |
#member_of_works ⇒ Object
131 132 133 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 131 def member_of_works in_objects.to_a.select(&:work?) end |
#member_work_ids ⇒ Object
78 79 80 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 78 def member_work_ids member_works.map(&:id) end |
#member_works ⇒ Object
72 73 74 75 76 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 72 def member_works return [] if id.nil? member_objects = ActiveFedora::Base.where('object_ids_ssim' => id) member_objects.select(&:work?).to_a end |
#ordered_file_set_ids ⇒ Object
103 104 105 106 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 103 def ordered_file_set_ids Deprecation.warn WorkBehavior, "ordered_file_set_ids is deprecated and will be removed in Hydra::Works 1.0. If you need order, use an interstitial work node." ordered_file_sets.map(&:id) end |
#ordered_file_sets ⇒ Object
98 99 100 101 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 98 def ordered_file_sets Deprecation.warn WorkBehavior, "ordered_file_sets is deprecated and will be removed in Hydra::Works 1.0. If you need order, use an interstitial work node." ordered_members.to_a.select(&:file_set?) end |
#ordered_work_ids ⇒ Object
86 87 88 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 86 def ordered_work_ids ordered_works.map(&:id) end |
#ordered_works ⇒ Object
82 83 84 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 82 def ordered_works ordered_members.to_a.select(&:work?) end |
#parent_collection_ids ⇒ Object
36 37 38 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 36 def parent_collection_ids in_collection_ids + member_of_collection_ids end |
#parent_collections ⇒ Object
32 33 34 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 32 def parent_collections in_collections + member_of_collections end |
#parent_work_ids ⇒ Object
44 45 46 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 44 def parent_work_ids in_work_ids + member_of_work_ids end |
#parent_works ⇒ Object
40 41 42 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 40 def parent_works in_works + member_of_works end |
#work? ⇒ Boolean
Returns whether this instance is a Hydra::Works Generic Work.
114 115 116 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 114 def work? true end |
#work_ids ⇒ Object
68 69 70 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 68 def work_ids works.map(&:id) end |
#works ⇒ Object
64 65 66 |
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 64 def works members.select(&:work?) end |