active-fedora 9.9.1 → 9.10.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.rubocop.yml +4 -2
 - data/.travis.yml +2 -6
 - data/active-fedora.gemspec +9 -6
 - data/lib/active_fedora.rb +31 -15
 - data/lib/active_fedora/associations.rb +1 -1
 - data/lib/active_fedora/associations/association.rb +6 -2
 - data/lib/active_fedora/associations/belongs_to_association.rb +0 -10
 - data/lib/active_fedora/associations/builder/association.rb +85 -12
 - data/lib/active_fedora/associations/builder/belongs_to.rb +3 -1
 - data/lib/active_fedora/associations/builder/collection_association.rb +4 -3
 - data/lib/active_fedora/associations/builder/contains.rb +7 -2
 - data/lib/active_fedora/associations/builder/directly_contains.rb +7 -3
 - data/lib/active_fedora/associations/builder/directly_contains_one.rb +8 -4
 - data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +6 -2
 - data/lib/active_fedora/associations/builder/has_many.rb +6 -2
 - data/lib/active_fedora/associations/builder/indirectly_contains.rb +7 -3
 - data/lib/active_fedora/associations/builder/property.rb +7 -2
 - data/lib/active_fedora/associations/builder/singular_association.rb +3 -1
 - data/lib/active_fedora/associations/builder/singular_property.rb +3 -1
 - data/lib/active_fedora/associations/collection_association.rb +9 -5
 - data/lib/active_fedora/associations/collection_proxy.rb +1 -1
 - data/lib/active_fedora/associations/contained_finder.rb +1 -2
 - data/lib/active_fedora/associations/directly_contains_one_association.rb +1 -1
 - data/lib/active_fedora/associations/has_many_association.rb +1 -5
 - data/lib/active_fedora/associations/rdf.rb +1 -20
 - data/lib/active_fedora/attached_files.rb +1 -1
 - data/lib/active_fedora/attribute_methods.rb +18 -0
 - data/lib/active_fedora/attributes.rb +1 -1
 - data/lib/active_fedora/autosave_association.rb +8 -12
 - data/lib/active_fedora/base.rb +0 -2
 - data/lib/active_fedora/caching_connection.rb +1 -1
 - data/lib/active_fedora/default_model_mapper.rb +24 -0
 - data/lib/active_fedora/fedora.rb +1 -1
 - data/lib/active_fedora/file/attributes.rb +4 -5
 - data/lib/active_fedora/identifiable.rb +5 -0
 - data/lib/active_fedora/indexing.rb +13 -7
 - data/lib/active_fedora/indexing_service.rb +4 -4
 - data/lib/active_fedora/ldp_resource.rb +1 -0
 - data/lib/active_fedora/model.rb +18 -16
 - data/lib/active_fedora/model_classifier.rb +77 -0
 - data/lib/active_fedora/nested_attributes.rb +145 -18
 - data/lib/active_fedora/persistence.rb +1 -1
 - data/lib/active_fedora/predicates.rb +3 -0
 - data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
 - data/lib/active_fedora/query_result_builder.rb +12 -28
 - data/lib/active_fedora/querying.rb +1 -1
 - data/lib/active_fedora/rdf/datastream_indexing.rb +1 -1
 - data/lib/active_fedora/reflection.rb +15 -7
 - data/lib/active_fedora/relation.rb +17 -0
 - data/lib/active_fedora/relation/calculations.rb +1 -5
 - data/lib/active_fedora/relation/finder_methods.rb +39 -26
 - data/lib/active_fedora/scoping.rb +5 -0
 - data/lib/active_fedora/scoping/default.rb +113 -0
 - data/lib/active_fedora/scoping/named.rb +11 -3
 - data/lib/active_fedora/simple_datastream.rb +1 -1
 - data/lib/active_fedora/solr_hit.rb +71 -0
 - data/lib/active_fedora/solr_instance_loader.rb +12 -36
 - data/lib/active_fedora/solr_query_builder.rb +20 -25
 - data/lib/active_fedora/solr_service.rb +24 -13
 - data/lib/active_fedora/type.rb +8 -0
 - data/lib/active_fedora/type/boolean.rb +23 -0
 - data/lib/active_fedora/type/value.rb +118 -0
 - data/lib/active_fedora/validations.rb +14 -5
 - data/lib/active_fedora/version.rb +1 -1
 - data/lib/active_fedora/versionable.rb +8 -7
 - data/spec/config_helper.rb +0 -5
 - data/spec/integration/associations_spec.rb +5 -5
 - data/spec/integration/base_spec.rb +4 -4
 - data/spec/integration/bug_spec.rb +0 -1
 - data/spec/integration/full_featured_model_spec.rb +4 -4
 - data/spec/integration/has_and_belongs_to_many_associations_spec.rb +1 -1
 - data/spec/integration/has_many_associations_spec.rb +30 -1
 - data/spec/integration/indirect_container_spec.rb +1 -1
 - data/spec/integration/nested_attribute_spec.rb +6 -0
 - data/spec/integration/ntriples_datastream_spec.rb +4 -4
 - data/spec/integration/om_datastream_spec.rb +1 -1
 - data/spec/integration/relation_delegation_spec.rb +1 -1
 - data/spec/integration/scoped_query_spec.rb +12 -12
 - data/spec/integration/solr_hit_spec.rb +52 -0
 - data/spec/samples/hydra-mods_article_datastream.rb +2 -2
 - data/spec/spec_helper.rb +5 -9
 - data/spec/unit/active_fedora_spec.rb +0 -26
 - data/spec/unit/base_spec.rb +20 -0
 - data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -3
 - data/spec/unit/callback_spec.rb +3 -8
 - data/spec/unit/default_model_mapper_spec.rb +39 -0
 - data/spec/unit/finder_methods_spec.rb +30 -6
 - data/spec/unit/has_many_association_spec.rb +23 -1
 - data/spec/unit/indexing_spec.rb +17 -3
 - data/spec/unit/model_classifier_spec.rb +49 -0
 - data/spec/unit/model_spec.rb +0 -9
 - data/spec/unit/ntriples_datastream_spec.rb +16 -16
 - data/spec/unit/om_datastream_spec.rb +7 -7
 - data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
 - data/spec/unit/query_result_builder_spec.rb +4 -10
 - data/spec/unit/query_spec.rb +28 -28
 - data/spec/unit/rdf/indexing_service_spec.rb +16 -16
 - data/spec/unit/scoping_spec.rb +67 -0
 - data/spec/unit/simple_datastream_spec.rb +2 -2
 - data/spec/unit/solr_config_options_spec.rb +29 -32
 - data/spec/unit/solr_hit_spec.rb +58 -0
 - data/spec/unit/solr_query_builder_spec.rb +9 -1
 - data/spec/unit/solr_service_spec.rb +19 -3
 - metadata +73 -17
 - data/spec/support/freeze_mocks.rb +0 -12
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7df084ee06f2755c8ff2fc057f8b6a8751bd142a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 622c46cd850334fe1950625b1e9a5b869f0dd2c0
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: df6c6b7f8af5f3e511434c06b0e667a3234841c4483dac0a7f508cddf89d4e056a087d7ea2186ea0b454133ff8b027e692bd8acf190bd93a4969c7effd874d09
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 17116f1df54b097ad14272537509d976f3eb9dd9f8911dca31c6ea80ce478af5c398255066628b5620938b5ee3a393a15af58577ac2d7ed3c88bf19e91df47ea
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    | 
         @@ -1,5 +1,3 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require: rubocop-rspec
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
1 
     | 
    
         
             
            AllCops:
         
     | 
| 
       4 
2 
     | 
    
         
             
              TargetRubyVersion: 2.2
         
     | 
| 
       5 
3 
     | 
    
         
             
              DisplayCopNames: true
         
     | 
| 
         @@ -58,6 +56,7 @@ Metrics/PerceivedComplexity: 
     | 
|
| 
       58 
56 
     | 
    
         
             
                - 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
         
     | 
| 
       59 
57 
     | 
    
         
             
                - 'lib/active_fedora/associations/builder/indirectly_contains.rb'
         
     | 
| 
       60 
58 
     | 
    
         
             
                - 'lib/active_fedora/associations/builder/directly_contains_one.rb'
         
     | 
| 
      
 59 
     | 
    
         
            +
                - 'lib/active_fedora/associations/collection_association.rb'
         
     | 
| 
       61 
60 
     | 
    
         | 
| 
       62 
61 
     | 
    
         
             
            Metrics/ModuleLength:
         
     | 
| 
       63 
62 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -67,6 +66,7 @@ Metrics/ModuleLength: 
     | 
|
| 
       67 
66 
     | 
    
         
             
                - 'lib/active_fedora/attributes.rb'
         
     | 
| 
       68 
67 
     | 
    
         
             
                - 'lib/active_fedora/autosave_association.rb'
         
     | 
| 
       69 
68 
     | 
    
         
             
                - 'lib/active_fedora/attached_files.rb'
         
     | 
| 
      
 69 
     | 
    
         
            +
                - 'lib/active_fedora/nested_attributes.rb'
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
            Metrics/ClassLength:
         
     | 
| 
       72 
72 
     | 
    
         
             
              Exclude:
         
     | 
| 
         @@ -76,6 +76,8 @@ Metrics/ClassLength: 
     | 
|
| 
       76 
76 
     | 
    
         
             
                - 'lib/active_fedora/qualified_dublin_core_datastream.rb'
         
     | 
| 
       77 
77 
     | 
    
         
             
                - 'lib/active_fedora/file_configurator.rb'
         
     | 
| 
       78 
78 
     | 
    
         
             
                - 'lib/active_fedora/file.rb'
         
     | 
| 
      
 79 
     | 
    
         
            +
                - 'lib/active_fedora/associations/association.rb'
         
     | 
| 
      
 80 
     | 
    
         
            +
                - 'lib/active_fedora/associations/builder/association.rb'
         
     | 
| 
       79 
81 
     | 
    
         
             
                - 'lib/active_fedora/associations/collection_proxy.rb'
         
     | 
| 
       80 
82 
     | 
    
         
             
                - 'lib/active_fedora/associations/collection_association.rb'
         
     | 
| 
       81 
83 
     | 
    
         | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -2,17 +2,13 @@ language: ruby 
     | 
|
| 
       2 
2 
     | 
    
         
             
            cache: bundler
         
     | 
| 
       3 
3 
     | 
    
         
             
            sudo: false
         
     | 
| 
       4 
4 
     | 
    
         
             
            rvm:
         
     | 
| 
       5 
     | 
    
         
            -
              - 2. 
     | 
| 
       6 
     | 
    
         
            -
            matrix:
         
     | 
| 
       7 
     | 
    
         
            -
              include:
         
     | 
| 
       8 
     | 
    
         
            -
                - rvm: 2.1
         
     | 
| 
       9 
     | 
    
         
            -
                  env: "RAILS_VERSION=4.2.4"
         
     | 
| 
      
 5 
     | 
    
         
            +
              - 2.3.0
         
     | 
| 
       10 
6 
     | 
    
         | 
| 
       11 
7 
     | 
    
         
             
            notifications:
         
     | 
| 
       12 
8 
     | 
    
         
             
              irc: "irc.freenode.org#projecthydra"
         
     | 
| 
       13 
9 
     | 
    
         | 
| 
       14 
10 
     | 
    
         
             
            env:
         
     | 
| 
       15 
     | 
    
         
            -
              - "RAILS_VERSION=4. 
     | 
| 
      
 11 
     | 
    
         
            +
              - "RAILS_VERSION=4.2.6"
         
     | 
| 
       16 
12 
     | 
    
         | 
| 
       17 
13 
     | 
    
         
             
            global_env:
         
     | 
| 
       18 
14 
     | 
    
         
             
              - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
         
     | 
    
        data/active-fedora.gemspec
    CHANGED
    
    | 
         @@ -12,27 +12,30 @@ Gem::Specification.new do |s| 
     | 
|
| 
       12 
12 
     | 
    
         
             
              s.summary     = %q{A convenience libary for manipulating documents in the Fedora Repository.}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.license = "APACHE2"
         
     | 
| 
       15 
     | 
    
         
            -
              s.required_ruby_version 
     | 
| 
      
 15 
     | 
    
         
            +
              s.required_ruby_version = '~> 2.0'
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
              s.add_dependency 'rsolr',  
     | 
| 
      
 17 
     | 
    
         
            +
              s.add_dependency 'rsolr', '~> 1.0', '>= 1.0.10'
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.add_dependency 'solrizer', '~> 3.4'
         
     | 
| 
       18 
19 
     | 
    
         
             
              s.add_dependency 'om', '~> 3.1'
         
     | 
| 
       19 
20 
     | 
    
         
             
              s.add_dependency 'nom-xml', '>= 0.5.1'
         
     | 
| 
       20 
     | 
    
         
            -
              s.add_dependency "activesupport", '>= 4. 
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_dependency "activesupport", '>= 4.2', '< 6'
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_dependency "activemodel", '>= 4.2', '< 6'
         
     | 
| 
       21 
23 
     | 
    
         
             
              s.add_dependency "active-triples", '~> 0.7.1'
         
     | 
| 
       22 
24 
     | 
    
         
             
              s.add_dependency "rdf-rdfxml", '~> 1.1'
         
     | 
| 
       23 
25 
     | 
    
         
             
              s.add_dependency "linkeddata"
         
     | 
| 
       24 
26 
     | 
    
         
             
              s.add_dependency "deprecation"
         
     | 
| 
       25 
     | 
    
         
            -
              s.add_dependency "ldp", '~> 0. 
     | 
| 
      
 27 
     | 
    
         
            +
              s.add_dependency "ldp", '~> 0.5.0'
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
              s.add_development_dependency "rdoc"
         
     | 
| 
       28 
30 
     | 
    
         
             
              s.add_development_dependency "yard"
         
     | 
| 
       29 
     | 
    
         
            -
               
     | 
| 
      
 31 
     | 
    
         
            +
              # Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
         
     | 
| 
      
 32 
     | 
    
         
            +
              s.add_development_dependency "rake", '~> 10.0'
         
     | 
| 
       30 
33 
     | 
    
         
             
              s.add_development_dependency "solr_wrapper", "~> 0.4"
         
     | 
| 
       31 
34 
     | 
    
         
             
              s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
         
     | 
| 
       32 
35 
     | 
    
         
             
              s.add_development_dependency "rspec", "~> 3.0"
         
     | 
| 
       33 
36 
     | 
    
         
             
              s.add_development_dependency "rspec-its"
         
     | 
| 
       34 
37 
     | 
    
         
             
              s.add_development_dependency "equivalent-xml"
         
     | 
| 
       35 
     | 
    
         
            -
              s.add_development_dependency "simplecov", '~> 0. 
     | 
| 
      
 38 
     | 
    
         
            +
              s.add_development_dependency "simplecov", '~> 0.8'
         
     | 
| 
       36 
39 
     | 
    
         
             
              s.add_development_dependency "rubocop", '~> 0.37'
         
     | 
| 
       37 
40 
     | 
    
         
             
              s.add_development_dependency "rubocop-rspec", '~> 1.4'
         
     | 
| 
       38 
41 
     | 
    
         | 
    
        data/lib/active_fedora.rb
    CHANGED
    
    | 
         @@ -9,9 +9,6 @@ require 'active_support/core_ext/hash/indifferent_access' 
     | 
|
| 
       9 
9 
     | 
    
         
             
            require 'active_support/core_ext/hash/except'
         
     | 
| 
       10 
10 
     | 
    
         
             
            require 'active_triples'
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            SOLR_DOCUMENT_ID = Solrizer.default_field_mapper.id_field unless defined?(SOLR_DOCUMENT_ID)
         
     | 
| 
       13 
     | 
    
         
            -
            ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
12 
     | 
    
         
             
            # Monkey patching RDF::Literal::DateTime to support fractional seconds.
         
     | 
| 
       16 
13 
     | 
    
         
             
            # See https://github.com/projecthydra/active_fedora/issues/497
         
     | 
| 
       17 
14 
     | 
    
         
             
            # Also monkey patches in a fix for timezones to be stored properly.
         
     | 
| 
         @@ -68,6 +65,7 @@ module ActiveFedora #:nodoc: 
     | 
|
| 
       68 
65 
     | 
    
         
             
                  autoload :OmAttribute
         
     | 
| 
       69 
66 
     | 
    
         
             
                  autoload :RdfDatastreamAttribute
         
     | 
| 
       70 
67 
     | 
    
         
             
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
                autoload :DefaultModelMapper
         
     | 
| 
       71 
69 
     | 
    
         
             
                autoload :Fedora
         
     | 
| 
       72 
70 
     | 
    
         
             
                autoload :FedoraAttributes
         
     | 
| 
       73 
71 
     | 
    
         
             
                autoload :File
         
     | 
| 
         @@ -87,6 +85,7 @@ module ActiveFedora #:nodoc: 
     | 
|
| 
       87 
85 
     | 
    
         
             
                autoload :LdpResourceService
         
     | 
| 
       88 
86 
     | 
    
         
             
                autoload :LoadableFromJson
         
     | 
| 
       89 
87 
     | 
    
         
             
                autoload :Model
         
     | 
| 
      
 88 
     | 
    
         
            +
                autoload :ModelClassifier
         
     | 
| 
       90 
89 
     | 
    
         
             
                autoload :NestedAttributes
         
     | 
| 
       91 
90 
     | 
    
         
             
                autoload :NomDatastream
         
     | 
| 
       92 
91 
     | 
    
         
             
                autoload :NullRelation
         
     | 
| 
         @@ -121,11 +120,13 @@ module ActiveFedora #:nodoc: 
     | 
|
| 
       121 
120 
     | 
    
         
             
                autoload :Serialization
         
     | 
| 
       122 
121 
     | 
    
         
             
                autoload :SimpleDatastream
         
     | 
| 
       123 
122 
     | 
    
         
             
                autoload :SchemaIndexingStrategy
         
     | 
| 
      
 123 
     | 
    
         
            +
                autoload :SolrHit
         
     | 
| 
       124 
124 
     | 
    
         
             
                autoload :SolrInstanceLoader
         
     | 
| 
       125 
125 
     | 
    
         
             
                autoload :SolrQueryBuilder
         
     | 
| 
       126 
126 
     | 
    
         
             
                autoload :SolrService
         
     | 
| 
       127 
127 
     | 
    
         
             
                autoload :SparqlInsert
         
     | 
| 
       128 
128 
     | 
    
         
             
                autoload :Predicates
         
     | 
| 
      
 129 
     | 
    
         
            +
                autoload :Type
         
     | 
| 
       129 
130 
     | 
    
         
             
                autoload :Validations
         
     | 
| 
       130 
131 
     | 
    
         
             
                autoload :Versionable
         
     | 
| 
       131 
132 
     | 
    
         
             
                autoload :VersionsGraph
         
     | 
| 
         @@ -245,18 +246,33 @@ module ActiveFedora #:nodoc: 
     | 
|
| 
       245 
246 
     | 
    
         
             
                # @example Search within ActiveFedora::RdfNode for a class called "TermProxy"
         
     | 
| 
       246 
247 
     | 
    
         
             
                #   ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode)
         
     | 
| 
       247 
248 
     | 
    
         
             
                #   => ActiveFedora::RdfNode::TermProxy
         
     | 
| 
       248 
     | 
    
         
            -
                def class_from_string( 
     | 
| 
       249 
     | 
    
         
            -
                   
     | 
| 
       250 
     | 
    
         
            -
             
     | 
| 
       251 
     | 
    
         
            -
             
     | 
| 
       252 
     | 
    
         
            -
             
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
             
     | 
| 
       256 
     | 
    
         
            -
             
     | 
| 
       257 
     | 
    
         
            -
             
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
      
 249 
     | 
    
         
            +
                def class_from_string(*args)
         
     | 
| 
      
 250 
     | 
    
         
            +
                  ActiveFedora::ModelClassifier.class_from_string(*args)
         
     | 
| 
      
 251 
     | 
    
         
            +
                end
         
     | 
| 
      
 252 
     | 
    
         
            +
             
     | 
| 
      
 253 
     | 
    
         
            +
                def model_mapper
         
     | 
| 
      
 254 
     | 
    
         
            +
                  ActiveFedora::DefaultModelMapper.new
         
     | 
| 
      
 255 
     | 
    
         
            +
                end
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
                def index_field_mapper
         
     | 
| 
      
 258 
     | 
    
         
            +
                  Solrizer.default_field_mapper
         
     | 
| 
      
 259 
     | 
    
         
            +
                end
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
                def id_field
         
     | 
| 
      
 262 
     | 
    
         
            +
                  if defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?
         
     | 
| 
      
 263 
     | 
    
         
            +
                    SOLR_DOCUMENT_ID
         
     | 
| 
      
 264 
     | 
    
         
            +
                  elsif defined?(Solrizer)
         
     | 
| 
      
 265 
     | 
    
         
            +
                    Solrizer.default_field_mapper.id_field
         
     | 
| 
      
 266 
     | 
    
         
            +
                  else
         
     | 
| 
      
 267 
     | 
    
         
            +
                    'id'.freeze
         
     | 
| 
      
 268 
     | 
    
         
            +
                  end
         
     | 
| 
      
 269 
     | 
    
         
            +
                end
         
     | 
| 
      
 270 
     | 
    
         
            +
             
     | 
| 
      
 271 
     | 
    
         
            +
                def enable_solr_updates?
         
     | 
| 
      
 272 
     | 
    
         
            +
                  if defined?(ENABLE_SOLR_UPDATES)
         
     | 
| 
      
 273 
     | 
    
         
            +
                    ENABLE_SOLR_UPDATES
         
     | 
| 
      
 274 
     | 
    
         
            +
                  else
         
     | 
| 
      
 275 
     | 
    
         
            +
                    true
         
     | 
| 
       260 
276 
     | 
    
         
             
                  end
         
     | 
| 
       261 
277 
     | 
    
         
             
                end
         
     | 
| 
       262 
278 
     | 
    
         
             
              end
         
     | 
| 
         @@ -69,7 +69,7 @@ module ActiveFedora 
     | 
|
| 
       69 
69 
     | 
    
         
             
                  association = association_instance_get(name)
         
     | 
| 
       70 
70 
     | 
    
         | 
| 
       71 
71 
     | 
    
         
             
                  if association.nil?
         
     | 
| 
       72 
     | 
    
         
            -
                    reflection  = self.class. 
     | 
| 
      
 72 
     | 
    
         
            +
                    reflection  = self.class._reflect_on_association(name)
         
     | 
| 
       73 
73 
     | 
    
         
             
                    association = reflection.association_class.new(self, reflection) if reflection
         
     | 
| 
       74 
74 
     | 
    
         
             
                    association_instance_set(name, association) if association
         
     | 
| 
       75 
75 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -18,7 +18,7 @@ module ActiveFedora 
     | 
|
| 
       18 
18 
     | 
    
         
             
                    @owner = owner
         
     | 
| 
       19 
19 
     | 
    
         
             
                    @reflection = reflection
         
     | 
| 
       20 
20 
     | 
    
         
             
                    reset
         
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
      
 21 
     | 
    
         
            +
                    reset_scope
         
     | 
| 
       22 
22 
     | 
    
         
             
                  end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                  # Resets the \loaded flag to +false+ and sets the \target to +nil+.
         
     | 
| 
         @@ -32,7 +32,7 @@ module ActiveFedora 
     | 
|
| 
       32 
32 
     | 
    
         
             
                  # Reloads the \target and returns +self+ on success.
         
     | 
| 
       33 
33 
     | 
    
         
             
                  def reload
         
     | 
| 
       34 
34 
     | 
    
         
             
                    reset
         
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
      
 35 
     | 
    
         
            +
                    reset_scope
         
     | 
| 
       36 
36 
     | 
    
         
             
                    load_target
         
     | 
| 
       37 
37 
     | 
    
         
             
                    self unless @target.nil?
         
     | 
| 
       38 
38 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -79,6 +79,10 @@ module ActiveFedora 
     | 
|
| 
       79 
79 
     | 
    
         
             
                    @association_scope ||= AssociationScope.new(self).scope if klass
         
     | 
| 
       80 
80 
     | 
    
         
             
                  end
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
      
 82 
     | 
    
         
            +
                  def reset_scope
         
     | 
| 
      
 83 
     | 
    
         
            +
                    @association_scope = nil
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
       82 
86 
     | 
    
         
             
                  # Set the inverse association, if possible
         
     | 
| 
       83 
87 
     | 
    
         
             
                  def set_inverse_instance(record)
         
     | 
| 
       84 
88 
     | 
    
         
             
                    return unless record && invertible_for?(record)
         
     | 
| 
         @@ -36,16 +36,6 @@ module ActiveFedora 
     | 
|
| 
       36 
36 
     | 
    
         
             
                      owner[reflection.foreign_key] = nil
         
     | 
| 
       37 
37 
     | 
    
         
             
                    end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                    # Constructs a query that checks solr for the correct id & class_name combination
         
     | 
| 
       40 
     | 
    
         
            -
                    def construct_query(ids)
         
     | 
| 
       41 
     | 
    
         
            -
                      # Some descendants of ActiveFedora::Base are anonymous classes. They don't have names. Filter them out.
         
     | 
| 
       42 
     | 
    
         
            -
                      candidate_classes = klass.descendants.select(&:name)
         
     | 
| 
       43 
     | 
    
         
            -
                      candidate_classes += [klass] unless klass == ActiveFedora::Base
         
     | 
| 
       44 
     | 
    
         
            -
                      model_pairs = candidate_classes.each_with_object([]) { |klass, arr| arr << [:has_model, klass.to_class_uri] }
         
     | 
| 
       45 
     | 
    
         
            -
                      '(' + ActiveFedora::SolrQueryBuilder.construct_query_for_ids(ids) + ') AND (' +
         
     | 
| 
       46 
     | 
    
         
            -
                        ActiveFedora::SolrQueryBuilder.construct_query_for_rel(model_pairs, 'OR') + ')'
         
     | 
| 
       47 
     | 
    
         
            -
                    end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
39 
     | 
    
         
             
                    def foreign_key_present?
         
     | 
| 
       50 
40 
     | 
    
         
             
                      owner[reflection.foreign_key]
         
     | 
| 
       51 
41 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -1,21 +1,53 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module ActiveFedora::Associations::Builder
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Association #:nodoc:
         
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
                class << self
         
     | 
| 
      
 4 
     | 
    
         
            +
                  attr_accessor :extensions
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
                self.extensions = []
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                VALID_OPTIONS = [:class_name, :predicate, :type_validator].freeze
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                def self.macro
         
     | 
| 
      
 11 
     | 
    
         
            +
                  raise NotImplementedError
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
       5 
13 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
                def self.valid_options(_options)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  VALID_OPTIONS + Association.extensions.flat_map(&:valid_options)
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def self.validate_options(options)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  options.assert_valid_keys(valid_options(options))
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
       8 
21 
     | 
    
         | 
| 
       9 
22 
     | 
    
         
             
                attr_reader :model, :name, :options, :mixin
         
     | 
| 
       10 
23 
     | 
    
         | 
| 
       11 
24 
     | 
    
         
             
                # configure_dependency
         
     | 
| 
       12 
     | 
    
         
            -
                def self.build(model, name, options)
         
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
      
 25 
     | 
    
         
            +
                def self.build(model, name, options, &block)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  if model.dangerous_attribute_method?(name)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    Deprecation.warn(ActiveFedora::Base, "You tried to define an association named #{name} on the model #{model.name}, but " \
         
     | 
| 
      
 28 
     | 
    
         
            +
                                         "this will conflict with a method #{name} already defined by ActiveFedora. " \
         
     | 
| 
      
 29 
     | 
    
         
            +
                                         "Please choose a different association name.")
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  extension = define_extensions model, name, &block
         
     | 
| 
      
 33 
     | 
    
         
            +
                  reflection = create_reflection model, name, nil, options, extension
         
     | 
| 
       14 
34 
     | 
    
         
             
                  define_accessors(model, reflection)
         
     | 
| 
       15 
35 
     | 
    
         
             
                  define_callbacks(model, reflection)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  define_validations model, reflection
         
     | 
| 
       16 
37 
     | 
    
         
             
                  reflection
         
     | 
| 
       17 
38 
     | 
    
         
             
                end
         
     | 
| 
       18 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
                def self.create_reflection(model, name, _scope, options, _extension = nil)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  unless name.is_a?(Symbol)
         
     | 
| 
      
 42 
     | 
    
         
            +
                    name = name.to_sym
         
     | 
| 
      
 43 
     | 
    
         
            +
                    Deprecation.warn(ActiveFedora::Base, "association names must be a Symbol")
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                  validate_options(options)
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  new(model, name, options).build
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
       19 
51 
     | 
    
         
             
                def initialize(model, name, options)
         
     | 
| 
       20 
52 
     | 
    
         
             
                  @model = model
         
     | 
| 
       21 
53 
     | 
    
         
             
                  @name = name
         
     | 
| 
         @@ -36,7 +68,7 @@ module ActiveFedora::Associations::Builder 
     | 
|
| 
       36 
68 
     | 
    
         
             
                end
         
     | 
| 
       37 
69 
     | 
    
         | 
| 
       38 
70 
     | 
    
         
             
                def validate_options
         
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
      
 71 
     | 
    
         
            +
                  self.class.validate_options(options)
         
     | 
| 
       40 
72 
     | 
    
         
             
                end
         
     | 
| 
       41 
73 
     | 
    
         | 
| 
       42 
74 
     | 
    
         
             
                # Returns the RDF predicate as defined by the :property attribute
         
     | 
| 
         @@ -45,13 +77,26 @@ module ActiveFedora::Associations::Builder 
     | 
|
| 
       45 
77 
     | 
    
         
             
                  ActiveFedora::Predicates.find_graph_predicate(property)
         
     | 
| 
       46 
78 
     | 
    
         
             
                end
         
     | 
| 
       47 
79 
     | 
    
         | 
| 
      
 80 
     | 
    
         
            +
                def self.define_extensions(_model, _name)
         
     | 
| 
      
 81 
     | 
    
         
            +
                end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
       48 
83 
     | 
    
         
             
                def self.define_callbacks(model, reflection)
         
     | 
| 
       49 
84 
     | 
    
         
             
                  if dependent = reflection.options[:dependent]
         
     | 
| 
       50 
85 
     | 
    
         
             
                    check_dependent_options(dependent)
         
     | 
| 
       51 
86 
     | 
    
         
             
                    add_destroy_callbacks(model, reflection)
         
     | 
| 
       52 
87 
     | 
    
         
             
                  end
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                  Association.extensions.each do |extension|
         
     | 
| 
      
 90 
     | 
    
         
            +
                    extension.build model, reflection
         
     | 
| 
      
 91 
     | 
    
         
            +
                  end
         
     | 
| 
       53 
92 
     | 
    
         
             
                end
         
     | 
| 
       54 
93 
     | 
    
         | 
| 
      
 94 
     | 
    
         
            +
                # Defines the setter and getter methods for the association
         
     | 
| 
      
 95 
     | 
    
         
            +
                # class Post < ActiveRecord::Base
         
     | 
| 
      
 96 
     | 
    
         
            +
                #   has_many :comments
         
     | 
| 
      
 97 
     | 
    
         
            +
                # end
         
     | 
| 
      
 98 
     | 
    
         
            +
                #
         
     | 
| 
      
 99 
     | 
    
         
            +
                # Post.first.comments and Post.first.comments= methods are defined by this method...
         
     | 
| 
       55 
100 
     | 
    
         
             
                def self.define_accessors(model, reflection)
         
     | 
| 
       56 
101 
     | 
    
         
             
                  mixin = model.generated_association_methods
         
     | 
| 
       57 
102 
     | 
    
         
             
                  name = reflection.name
         
     | 
| 
         @@ -60,19 +105,47 @@ module ActiveFedora::Associations::Builder 
     | 
|
| 
       60 
105 
     | 
    
         
             
                end
         
     | 
| 
       61 
106 
     | 
    
         | 
| 
       62 
107 
     | 
    
         
             
                def self.define_readers(mixin, name)
         
     | 
| 
       63 
     | 
    
         
            -
                  mixin. 
     | 
| 
       64 
     | 
    
         
            -
                     
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
      
 108 
     | 
    
         
            +
                  mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
         
     | 
| 
      
 109 
     | 
    
         
            +
                    def #{name}(*args)
         
     | 
| 
      
 110 
     | 
    
         
            +
                      association(:#{name}).reader(*args)
         
     | 
| 
      
 111 
     | 
    
         
            +
                    end
         
     | 
| 
      
 112 
     | 
    
         
            +
                  CODE
         
     | 
| 
       66 
113 
     | 
    
         
             
                end
         
     | 
| 
       67 
114 
     | 
    
         | 
| 
       68 
115 
     | 
    
         
             
                def self.define_writers(mixin, name)
         
     | 
| 
       69 
     | 
    
         
            -
                  mixin. 
     | 
| 
       70 
     | 
    
         
            -
                     
     | 
| 
      
 116 
     | 
    
         
            +
                  mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
         
     | 
| 
      
 117 
     | 
    
         
            +
                    def #{name}=(value)
         
     | 
| 
      
 118 
     | 
    
         
            +
                      association(:#{name}).writer(value)
         
     | 
| 
      
 119 
     | 
    
         
            +
                    end
         
     | 
| 
      
 120 
     | 
    
         
            +
                  CODE
         
     | 
| 
      
 121 
     | 
    
         
            +
                end
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                def self.define_validations(_model, _reflection)
         
     | 
| 
      
 124 
     | 
    
         
            +
                  # noop
         
     | 
| 
      
 125 
     | 
    
         
            +
                end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                def self.add_destroy_callbacks(model, reflection)
         
     | 
| 
      
 128 
     | 
    
         
            +
                  name = reflection.name
         
     | 
| 
      
 129 
     | 
    
         
            +
                  model.before_destroy lambda do |o|
         
     | 
| 
      
 130 
     | 
    
         
            +
                    a = o.association(name)
         
     | 
| 
      
 131 
     | 
    
         
            +
                    a.handle_dependency if a.respond_to? :handle_dependency
         
     | 
| 
      
 132 
     | 
    
         
            +
                  end
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                def self.valid_dependent_options
         
     | 
| 
      
 136 
     | 
    
         
            +
                  raise NotImplementedError
         
     | 
| 
      
 137 
     | 
    
         
            +
                end
         
     | 
| 
      
 138 
     | 
    
         
            +
             
     | 
| 
      
 139 
     | 
    
         
            +
                def self.check_dependent_options(dependent)
         
     | 
| 
      
 140 
     | 
    
         
            +
                  unless valid_dependent_options.include? dependent
         
     | 
| 
      
 141 
     | 
    
         
            +
                    raise ArgumentError, "The :dependent option must be one of #{valid_dependent_options}, but is :#{dependent}"
         
     | 
| 
       71 
142 
     | 
    
         
             
                  end
         
     | 
| 
       72 
143 
     | 
    
         
             
                end
         
     | 
| 
       73 
144 
     | 
    
         | 
| 
       74 
145 
     | 
    
         
             
                def configure_dependency
         
     | 
| 
       75 
146 
     | 
    
         
             
                  return unless options[:dependent]
         
     | 
| 
      
 147 
     | 
    
         
            +
                  return if model.association(name).respond_to? :handle_dependency
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
       76 
149 
     | 
    
         
             
                  unless [:destroy, :delete].include?(options[:dependent])
         
     | 
| 
       77 
150 
     | 
    
         
             
                    raise ArgumentError, "The :dependent option expects either :destroy or :delete (#{options[:dependent].inspect})"
         
     | 
| 
       78 
151 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -3,13 +3,14 @@ module ActiveFedora::Associations::Builder 
     | 
|
| 
       3 
3 
     | 
    
         
             
              class CollectionAssociation < Association #:nodoc:
         
     | 
| 
       4 
4 
     | 
    
         
             
                CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove].freeze
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
                self.valid_options 
     | 
| 
       7 
     | 
    
         
            -
                   
     | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                def self.valid_options(options)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  super + CALLBACKS
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                def self.define_callbacks(model, reflection)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  name = reflection.name
         
     | 
| 
       12 
12 
     | 
    
         
             
                  options = reflection.options
         
     | 
| 
      
 13 
     | 
    
         
            +
                  super
         
     | 
| 
       13 
14 
     | 
    
         
             
                  CALLBACKS.each { |callback_name| define_callback(model, callback_name, name, options) }
         
     | 
| 
       14 
15 
     | 
    
         
             
                end
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
         @@ -1,7 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module ActiveFedora::Associations::Builder
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Contains < SingularAssociation #:nodoc:
         
     | 
| 
       3 
     | 
    
         
            -
                self.macro 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
                def self.macro
         
     | 
| 
      
 4 
     | 
    
         
            +
                  :contains
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def self.valid_options(options)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  super + [:autocreate, :block]
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
       5 
10 
     | 
    
         | 
| 
       6 
11 
     | 
    
         
             
                def initialize(model, name, options)
         
     | 
| 
       7 
12 
     | 
    
         
             
                  super
         
     | 
| 
         @@ -1,8 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module ActiveFedora::Associations::Builder
         
     | 
| 
       2 
2 
     | 
    
         
             
              class DirectlyContains < CollectionAssociation #:nodoc:
         
     | 
| 
       3 
     | 
    
         
            -
                self.macro 
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                 
     | 
| 
      
 3 
     | 
    
         
            +
                def self.macro
         
     | 
| 
      
 4 
     | 
    
         
            +
                  :directly_contains
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def self.valid_options(options)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  super + [:has_member_relation, :is_member_of_relation] - [:predicate]
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
       6 
10 
     | 
    
         | 
| 
       7 
11 
     | 
    
         
             
                def build
         
     | 
| 
       8 
12 
     | 
    
         
             
                  reflection = super
         
     |