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

Instance Method Details

#child_file_set_idsObject



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_setsObject



56
57
58
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 56

def child_file_sets
  file_sets
end

#child_work_idsObject



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_worksObject



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.

Returns:

  • (Boolean)

    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.

Returns:

  • (Boolean)

    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_idsObject



94
95
96
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 94

def file_set_ids
  file_sets.map(&:id)
end

#file_setsObject



90
91
92
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 90

def file_sets
  members.select(&:file_set?)
end

#in_work_idsObject



127
128
129
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 127

def in_work_ids
  in_works.map(&:id)
end

#in_worksObject



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_idsObject



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_worksObject



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_idsObject



78
79
80
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 78

def member_work_ids
  member_works.map(&:id)
end

#member_worksObject



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_idsObject



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_setsObject



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_idsObject



86
87
88
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 86

def ordered_work_ids
  ordered_works.map(&:id)
end

#ordered_worksObject



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_idsObject



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_collectionsObject



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_idsObject



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_worksObject



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.

Returns:

  • (Boolean)

    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_idsObject



68
69
70
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 68

def work_ids
  works.map(&:id)
end

#worksObject



64
65
66
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 64

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