Class: Hyrax::ResourceStatus
- Inherits:
-
Object
- Object
- Hyrax::ResourceStatus
- Defined in:
- app/services/hyrax/resource_status.rb
Overview
Implements the Fedora objState ontology against the given resource.
Use the provided constants as values for ‘#status` to set state. The boolean methods provide easy checking of state.
We assume that no-state, means none of the three object statuses are satisfied. Errors are raised if the ‘#state` attribute isn’t defined.
Constant Summary collapse
- ACTIVE =
Vocab::FedoraResourceStatus.active.freeze
- DELETED =
Vocab::FedoraResourceStatus.deleted.freeze
- INACTIVE =
Vocab::FedoraResourceStatus.inactive.freeze
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #active? ⇒ Boolean
- #deleted? ⇒ Boolean
- #inactive? ⇒ Boolean
-
#initialize(resource:) ⇒ ResourceStatus
constructor
A new instance of ResourceStatus.
Constructor Details
#initialize(resource:) ⇒ ResourceStatus
Returns a new instance of ResourceStatus.
35 36 37 |
# File 'app/services/hyrax/resource_status.rb', line 35 def initialize(resource:) self.resource = resource end |
Instance Attribute Details
#resource ⇒ #state
31 32 33 |
# File 'app/services/hyrax/resource_status.rb', line 31 def resource @resource end |
Class Method Details
.inactive?(resource:) ⇒ Boolean
42 43 44 |
# File 'app/services/hyrax/resource_status.rb', line 42 def self.inactive?(resource:) new(resource: resource).inactive? end |
Instance Method Details
#active? ⇒ Boolean
49 50 51 |
# File 'app/services/hyrax/resource_status.rb', line 49 def active? resource.state == ACTIVE end |
#deleted? ⇒ Boolean
56 57 58 |
# File 'app/services/hyrax/resource_status.rb', line 56 def deleted? resource.state == DELETED end |
#inactive? ⇒ Boolean
63 64 65 |
# File 'app/services/hyrax/resource_status.rb', line 63 def inactive? resource.state == INACTIVE end |