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

#collection?Boolean

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

Returns:

  • (Boolean)

    whether this instance is a Hydra::Works Collection.



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

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.



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

def file_set?
  false
end

#file_set_idsObject



52
53
54
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 52

def file_set_ids
  file_sets.map(&:id)
end

#file_setsObject



48
49
50
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 48

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

#in_worksObject



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

def in_works
  ordered_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::WorkBehavior) }.to_a
end

#ordered_file_set_idsObject



61
62
63
64
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 61

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



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

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



44
45
46
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 44

def ordered_work_ids
  ordered_works.map(&:id)
end

#ordered_worksObject



40
41
42
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 40

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

#work?Boolean

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

Returns:

  • (Boolean)

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



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

def work?
  true
end

#work_idsObject



36
37
38
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 36

def work_ids
  works.map(&:id)
end

#worksObject



32
33
34
# File 'lib/hydra/works/models/concerns/work_behavior.rb', line 32

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