diff --git a/lib/active_fedora/delegating.rb b/lib/active_fedora/delegating.rb
index 469668483..605df138f 100644
--- a/lib/active_fedora/delegating.rb
+++ b/lib/active_fedora/delegating.rb
@@ -1,7 +1,6 @@
module ActiveFedora
module Delegating
extend ActiveSupport::Concern
- extend Deprecation
included do
after_save :clear_changed_attributes
@@ -146,29 +145,7 @@ def create_delegate_reader(field, args)
end
end
- if !args[:multiple].nil?
- self.delegates[field][:multiple] = args[:multiple]
- elsif !args[:unique].nil?
- i = 0
- begin
- match = /in `(delegate.*)'/.match(caller[i])
- i+=1
- end while match.nil?
-
- prev_method = match.captures.first
- Deprecation.warn Delegating, "The :unique option for `#{prev_method}' is deprecated. Use :multiple instead. :unique will be removed in ActiveFedora 7", caller(i+1)
- self.delegates[field][:multiple] = !args[:unique]
- else
- i = 0
- begin
- match = /in `(delegate.*)'/.match(caller[i])
- i+=1
- end while match.nil?
-
- prev_method = match.captures.first
- Deprecation.warn Delegating, "You have not explicitly set the :multiple option on `#{prev_method}'. The default value will switch from true to false in ActiveFedora 7, so if you want to future-proof this application set `multiple: true'", caller(i+ 1)
- self.delegates[field][:multiple] = true # this should be false for ActiveFedora 7
- end
+ self.delegates[field][:multiple] = args[:multiple].nil? ? false : args[:multiple]
define_method field do |*opts|
val = array_reader(field, *opts)
diff --git a/spec/unit/base_delegate_spec.rb b/spec/unit/base_delegate_spec.rb
index b791f6f58..484bdf1c3 100644
--- a/spec/unit/base_delegate_spec.rb
+++ b/spec/unit/base_delegate_spec.rb
@@ -23,7 +23,6 @@ def self.xml_template
-
'
end
@@ -49,9 +48,8 @@ class BarHistory2 < ActiveFedora::Base
end
has_metadata :type=>BarStream2, :name=>"xmlish"
- delegate :fubar, :to=>'withText', :unique=>true
- delegate :donkey, :to=>'xmlish', :unique=>true
- delegate :cow, :to=>'xmlish' # for testing the default value of multiple
+ delegate :cow, :to=>'xmlish' # for testing the default value of multiple
+ delegate :fubar, :to=>'withText', multiple: true # test alternate datastream
delegate :pig, :to=>'xmlish', multiple: false
delegate :horse, :to=>'xmlish', multiple: true
delegate :duck, :to=>'xmlish', :at=>[:waterfowl, :ducks], multiple: true
@@ -65,17 +63,18 @@ class BarHistory2 < ActiveFedora::Base
subject { BarHistory2.new() }
it "should reveal the unique properties" do
- BarHistory2.unique?(:fubar).should be_true
- BarHistory2.unique?(:cow).should be_false
+ BarHistory2.unique?(:horse).should be_false
+ BarHistory2.unique?(:pig).should be_true
+ BarHistory2.unique?(:cow).should be_true
end
it "should save a delegated property uniquely" do
subject.fubar="Quack"
- subject.fubar.should == "Quack"
+ subject.fubar.should == ["Quack"]
subject.withText.get_values(:fubar).first.should == 'Quack'
- subject.donkey="Bray"
- subject.donkey.should == "Bray"
- subject.xmlish.term_values(:donkey).first.should == 'Bray'
+ subject.cow="Low"
+ subject.cow.should == "Low"
+ subject.xmlish.term_values(:cow).first.should == 'Low'
subject.pig="Oink"
subject.pig.should == "Oink"
@@ -83,15 +82,15 @@ class BarHistory2 < ActiveFedora::Base
it "should allow passing parameters to the delegate accessor" do
subject.cow=["one", "two"]
- subject.cow(1).should == ['two']
+ subject.cow(1).should == 'two'
end
-
- it "should return an array if not marked as unique" do
- ### Metadata datastream does not appear to support multiple value setting
+ it "should return a single value if not marked as multiple" do
subject.cow=["one", "two"]
- subject.cow.should == ["one", "two"]
+ subject.cow.should == "one"
+ end
+ it "should return an array if marked as multiple" do
subject.horse=["neigh", "whinny"]
subject.horse.should == ["neigh", "whinny"]
end