Class: ActiveFedora::Associations::Builder::DirectlyContainsOne
- Inherits:
-
SingularAssociation
- Object
- Association
- SingularAssociation
- ActiveFedora::Associations::Builder::DirectlyContainsOne
- Defined in:
- lib/active_fedora/associations/builder/directly_contains_one.rb
Overview
:nodoc:
Constant Summary
Constants inherited from Association
Class Method Summary collapse
- .create_reflection(model, name, scope, options, extension = nil) ⇒ Object
- .macro ⇒ Object
- .valid_options(options) ⇒ Object
-
.validate_options(options) ⇒ Object
rubocop:disable Style/GuardClause.
Methods inherited from SingularAssociation
define_accessors, define_constructors
Methods inherited from Association
add_destroy_callbacks, better_name, build, build_scope, check_dependent_options, define_accessors, define_callbacks, define_extensions, define_readers, define_validations, define_writers, valid_dependent_options, wrap_scope
Class Method Details
.create_reflection(model, name, scope, options, extension = nil) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/active_fedora/associations/builder/directly_contains_one.rb', line 11 def self.create_reflection(model, name, scope, , extension = nil) raise ArgumentError, "you must specify a :through option on #{name}. #{name} will use the container from that directly_contains association." unless [:through] (model, , [:through]) super end |
.macro ⇒ Object
3 4 5 |
# File 'lib/active_fedora/associations/builder/directly_contains_one.rb', line 3 def self.macro :directly_contains_one end |
.valid_options(options) ⇒ Object
7 8 9 |
# File 'lib/active_fedora/associations/builder/directly_contains_one.rb', line 7 def self.() super + [:has_member_relation, :is_member_of_relation, :type, :through] - [:predicate] end |
.validate_options(options) ⇒ Object
rubocop:disable Style/GuardClause
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_fedora/associations/builder/directly_contains_one.rb', line 19 def self.() super if [:class_name] == "ActiveFedora::File" raise ArgumentError, "You cannot set :class_name of #{name} to ActiveFedora::File because directly_contains_one needs to assert and read RDF.type assertions, which is not supported by ActiveFedora::File. To make Files support RDF.type assertions, define a subclass of ActiveFedora::File and make it `include ActiveFedora::WithMetadata`. Otherwise, all subclasses of ActiveFedora::Base support RDF.type assertions." elsif ![:has_member_relation] && ![:is_member_of_relation] raise ArgumentError, "You must specify a :has_member_relation or :is_member_of_relation predicate for #{name}" elsif ![:has_member_relation].is_a?(RDF::URI) && ![:is_member_of_relation].is_a?(RDF::URI) raise ArgumentError, "Predicate must be a kind of RDF::URI" end return if [:type].is_a?(RDF::URI) raise ArgumentError, "You must specify a Type and it must be a kind of RDF::URI" end |