active-fedora 9.9.1 → 9.10.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -2
  3. data/.travis.yml +2 -6
  4. data/active-fedora.gemspec +9 -6
  5. data/lib/active_fedora.rb +31 -15
  6. data/lib/active_fedora/associations.rb +1 -1
  7. data/lib/active_fedora/associations/association.rb +6 -2
  8. data/lib/active_fedora/associations/belongs_to_association.rb +0 -10
  9. data/lib/active_fedora/associations/builder/association.rb +85 -12
  10. data/lib/active_fedora/associations/builder/belongs_to.rb +3 -1
  11. data/lib/active_fedora/associations/builder/collection_association.rb +4 -3
  12. data/lib/active_fedora/associations/builder/contains.rb +7 -2
  13. data/lib/active_fedora/associations/builder/directly_contains.rb +7 -3
  14. data/lib/active_fedora/associations/builder/directly_contains_one.rb +8 -4
  15. data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +6 -2
  16. data/lib/active_fedora/associations/builder/has_many.rb +6 -2
  17. data/lib/active_fedora/associations/builder/indirectly_contains.rb +7 -3
  18. data/lib/active_fedora/associations/builder/property.rb +7 -2
  19. data/lib/active_fedora/associations/builder/singular_association.rb +3 -1
  20. data/lib/active_fedora/associations/builder/singular_property.rb +3 -1
  21. data/lib/active_fedora/associations/collection_association.rb +9 -5
  22. data/lib/active_fedora/associations/collection_proxy.rb +1 -1
  23. data/lib/active_fedora/associations/contained_finder.rb +1 -2
  24. data/lib/active_fedora/associations/directly_contains_one_association.rb +1 -1
  25. data/lib/active_fedora/associations/has_many_association.rb +1 -5
  26. data/lib/active_fedora/associations/rdf.rb +1 -20
  27. data/lib/active_fedora/attached_files.rb +1 -1
  28. data/lib/active_fedora/attribute_methods.rb +18 -0
  29. data/lib/active_fedora/attributes.rb +1 -1
  30. data/lib/active_fedora/autosave_association.rb +8 -12
  31. data/lib/active_fedora/base.rb +0 -2
  32. data/lib/active_fedora/caching_connection.rb +1 -1
  33. data/lib/active_fedora/default_model_mapper.rb +24 -0
  34. data/lib/active_fedora/fedora.rb +1 -1
  35. data/lib/active_fedora/file/attributes.rb +4 -5
  36. data/lib/active_fedora/identifiable.rb +5 -0
  37. data/lib/active_fedora/indexing.rb +13 -7
  38. data/lib/active_fedora/indexing_service.rb +4 -4
  39. data/lib/active_fedora/ldp_resource.rb +1 -0
  40. data/lib/active_fedora/model.rb +18 -16
  41. data/lib/active_fedora/model_classifier.rb +77 -0
  42. data/lib/active_fedora/nested_attributes.rb +145 -18
  43. data/lib/active_fedora/persistence.rb +1 -1
  44. data/lib/active_fedora/predicates.rb +3 -0
  45. data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
  46. data/lib/active_fedora/query_result_builder.rb +12 -28
  47. data/lib/active_fedora/querying.rb +1 -1
  48. data/lib/active_fedora/rdf/datastream_indexing.rb +1 -1
  49. data/lib/active_fedora/reflection.rb +15 -7
  50. data/lib/active_fedora/relation.rb +17 -0
  51. data/lib/active_fedora/relation/calculations.rb +1 -5
  52. data/lib/active_fedora/relation/finder_methods.rb +39 -26
  53. data/lib/active_fedora/scoping.rb +5 -0
  54. data/lib/active_fedora/scoping/default.rb +113 -0
  55. data/lib/active_fedora/scoping/named.rb +11 -3
  56. data/lib/active_fedora/simple_datastream.rb +1 -1
  57. data/lib/active_fedora/solr_hit.rb +71 -0
  58. data/lib/active_fedora/solr_instance_loader.rb +12 -36
  59. data/lib/active_fedora/solr_query_builder.rb +20 -25
  60. data/lib/active_fedora/solr_service.rb +24 -13
  61. data/lib/active_fedora/type.rb +8 -0
  62. data/lib/active_fedora/type/boolean.rb +23 -0
  63. data/lib/active_fedora/type/value.rb +118 -0
  64. data/lib/active_fedora/validations.rb +14 -5
  65. data/lib/active_fedora/version.rb +1 -1
  66. data/lib/active_fedora/versionable.rb +8 -7
  67. data/spec/config_helper.rb +0 -5
  68. data/spec/integration/associations_spec.rb +5 -5
  69. data/spec/integration/base_spec.rb +4 -4
  70. data/spec/integration/bug_spec.rb +0 -1
  71. data/spec/integration/full_featured_model_spec.rb +4 -4
  72. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +1 -1
  73. data/spec/integration/has_many_associations_spec.rb +30 -1
  74. data/spec/integration/indirect_container_spec.rb +1 -1
  75. data/spec/integration/nested_attribute_spec.rb +6 -0
  76. data/spec/integration/ntriples_datastream_spec.rb +4 -4
  77. data/spec/integration/om_datastream_spec.rb +1 -1
  78. data/spec/integration/relation_delegation_spec.rb +1 -1
  79. data/spec/integration/scoped_query_spec.rb +12 -12
  80. data/spec/integration/solr_hit_spec.rb +52 -0
  81. data/spec/samples/hydra-mods_article_datastream.rb +2 -2
  82. data/spec/spec_helper.rb +5 -9
  83. data/spec/unit/active_fedora_spec.rb +0 -26
  84. data/spec/unit/base_spec.rb +20 -0
  85. data/spec/unit/builder/has_and_belongs_to_many_spec.rb +2 -3
  86. data/spec/unit/callback_spec.rb +3 -8
  87. data/spec/unit/default_model_mapper_spec.rb +39 -0
  88. data/spec/unit/finder_methods_spec.rb +30 -6
  89. data/spec/unit/has_many_association_spec.rb +23 -1
  90. data/spec/unit/indexing_spec.rb +17 -3
  91. data/spec/unit/model_classifier_spec.rb +49 -0
  92. data/spec/unit/model_spec.rb +0 -9
  93. data/spec/unit/ntriples_datastream_spec.rb +16 -16
  94. data/spec/unit/om_datastream_spec.rb +7 -7
  95. data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
  96. data/spec/unit/query_result_builder_spec.rb +4 -10
  97. data/spec/unit/query_spec.rb +28 -28
  98. data/spec/unit/rdf/indexing_service_spec.rb +16 -16
  99. data/spec/unit/scoping_spec.rb +67 -0
  100. data/spec/unit/simple_datastream_spec.rb +2 -2
  101. data/spec/unit/solr_config_options_spec.rb +29 -32
  102. data/spec/unit/solr_hit_spec.rb +58 -0
  103. data/spec/unit/solr_query_builder_spec.rb +9 -1
  104. data/spec/unit/solr_service_spec.rb +19 -3
  105. metadata +73 -17
  106. data/spec/support/freeze_mocks.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0ebc108c6b87dd9fe1a4dc327e64d3fa5e04339
4
- data.tar.gz: 7c77a4ebceaea68268ef3b57664816b95768e208
3
+ metadata.gz: 7df084ee06f2755c8ff2fc057f8b6a8751bd142a
4
+ data.tar.gz: 622c46cd850334fe1950625b1e9a5b869f0dd2c0
5
5
  SHA512:
6
- metadata.gz: c0e4a0fb65f9173bbc475a96a0c06cf559cfb95bb93038e7228facb653d6bc5ce03f7c283d706a9a2f527c362ead96e540b662f63e3fdd626128d85b69282d18
7
- data.tar.gz: 64c815e6c7aecea3ed9533d3a81b52c268f0982301ef367c9374bfb2764c5dae8ca06fe992158a406958d980882aac02c41da7c999a85add1d0b89fb4691654e
6
+ metadata.gz: df6c6b7f8af5f3e511434c06b0e667a3234841c4483dac0a7f508cddf89d4e056a087d7ea2186ea0b454133ff8b027e692bd8acf190bd93a4969c7effd874d09
7
+ data.tar.gz: 17116f1df54b097ad14272537509d976f3eb9dd9f8911dca31c6ea80ce478af5c398255066628b5620938b5ee3a393a15af58577ac2d7ed3c88bf19e91df47ea
@@ -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
 
@@ -2,17 +2,13 @@ language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
4
  rvm:
5
- - 2.2.1
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.1.13"
11
+ - "RAILS_VERSION=4.2.6"
16
12
 
17
13
  global_env:
18
14
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
@@ -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 = '>= 1.9.3'
15
+ s.required_ruby_version = '~> 2.0'
16
16
 
17
- s.add_dependency 'rsolr', "~> 1.0.10"
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.1.0'
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.4.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
- s.add_development_dependency "rake"
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.7.1'
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
 
@@ -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(full_class_name, container_class = Kernel)
249
- container_class = container_class.name if container_class.is_a? Module
250
- container_parts = container_class.split('::')
251
- (container_parts + full_class_name.split('::')).flatten.inject(Kernel) do |mod, class_name|
252
- if mod == Kernel
253
- Object.const_get(class_name)
254
- elsif mod.const_defined? class_name.to_sym
255
- mod.const_get(class_name)
256
- else
257
- container_parts.pop
258
- class_from_string(class_name, container_parts.join('::'))
259
- end
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.reflect_on_association(name)
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
- # construct_scope
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
- # construct_scope
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
- class_attribute :valid_options
4
- self.valid_options = [:class_name, :predicate, :type_validator]
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
- # Set by subclasses
7
- class_attribute :macro
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
- reflection = new(model, name, options).build
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
- options.assert_valid_keys(self.class.valid_options)
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.send(:define_method, name) do |*params|
64
- association(name).reader(*params)
65
- end
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.send(:define_method, "#{name}=") do |value|
70
- association(name).writer(value)
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
@@ -1,6 +1,8 @@
1
1
  module ActiveFedora::Associations::Builder
2
2
  class BelongsTo < SingularAssociation #:nodoc:
3
- self.macro = :belongs_to
3
+ def self.macro
4
+ :belongs_to
5
+ end
4
6
 
5
7
  def validate_options
6
8
  super
@@ -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
- :before_add, :after_add, :before_remove, :after_remove
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 = :contains
4
- self.valid_options += [:autocreate, :block]
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 = :directly_contains
4
- self.valid_options += [:has_member_relation, :is_member_of_relation]
5
- self.valid_options -= [:predicate]
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