Class: Hydra::PCDM::Validators::AncestorValidator
- Inherits:
-
Object
- Object
- Hydra::PCDM::Validators::AncestorValidator
- Defined in:
- lib/hydra/pcdm/validators/ancestor_validator.rb
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(owner, record) ⇒ AncestorValidator
constructor
A new instance of AncestorValidator.
- #validate! ⇒ Object
Constructor Details
#initialize(owner, record) ⇒ AncestorValidator
Returns a new instance of AncestorValidator.
8 9 10 11 |
# File 'lib/hydra/pcdm/validators/ancestor_validator.rb', line 8 def initialize(owner, record) @owner = owner @record = record end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
7 8 9 |
# File 'lib/hydra/pcdm/validators/ancestor_validator.rb', line 7 def owner @owner end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
7 8 9 |
# File 'lib/hydra/pcdm/validators/ancestor_validator.rb', line 7 def record @record end |
Class Method Details
.validate!(association, record) ⇒ Object
3 4 5 |
# File 'lib/hydra/pcdm/validators/ancestor_validator.rb', line 3 def self.validate!(association, record) new(association.owner, record).validate! end |
Instance Method Details
#validate! ⇒ Object
13 14 15 16 |
# File 'lib/hydra/pcdm/validators/ancestor_validator.rb', line 13 def validate! return unless owner.ancestor?(record) raise ArgumentError, "#{record.class} with ID: #{record.id} failed to pass AncestorChecker validation" end |