active-fedora 6.6.0 → 6.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +3 -0
- data/lib/active_fedora/delegating.rb +16 -1
- data/lib/active_fedora/version.rb +1 -1
- data/spec/integration/delegating_spec.rb +48 -21
- data/spec/integration/om_datastream_spec.rb +1 -1
- data/spec/unit/query_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95bf10c81395906f26c70a425466ec9e544f2e15
|
4
|
+
data.tar.gz: b18abff4428238811124584add40c90b6b58a1dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a2087217930bad433c30938c82bcc7416c66cc7552796466bf24c29e6e67cd099419b7e76914a09e66ae147b7c2b8bafa5178c1927e8f74311d283c21031a7d
|
7
|
+
data.tar.gz: 50d38ecf44e8959f978dab853f39d784a2f9d2168d0f6015e7a17e63b8c34a3f17a482064fdc1314a9af8b8b1eb4b0aa084555a3b4ba23a9ed053c9007a1daee
|
data/History.txt
CHANGED
@@ -41,6 +41,21 @@ module ActiveFedora
|
|
41
41
|
instance_exec(args, &self.class.delegates[field][:setter])
|
42
42
|
end
|
43
43
|
|
44
|
+
# @return [Boolean] true if there is an reader method and it returns a
|
45
|
+
# value different from the new_value.
|
46
|
+
def value_has_changed?(field, new_value)
|
47
|
+
begin
|
48
|
+
new_value != array_reader(field)
|
49
|
+
rescue NoMethodError
|
50
|
+
false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def mark_as_changed(field)
|
55
|
+
self.send("#{field}_will_change!")
|
56
|
+
end
|
57
|
+
|
58
|
+
|
44
59
|
module ClassMethods
|
45
60
|
def delegates
|
46
61
|
@local_delegates ||= {}.with_indifferent_access
|
@@ -181,7 +196,7 @@ module ActiveFedora
|
|
181
196
|
self.delegates[field] ||= {}
|
182
197
|
self.delegates[field][:setter] = lambda do |v|
|
183
198
|
ds = self.send(args[:to])
|
184
|
-
|
199
|
+
mark_as_changed(field) if value_has_changed?(field, v)
|
185
200
|
if ds.kind_of?(ActiveFedora::RDFDatastream)
|
186
201
|
ds.send("#{field}=", v)
|
187
202
|
else
|
@@ -1,32 +1,59 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "delegating
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe "delegating properties" do
|
4
|
+
describe "that have a reader and writer" do
|
5
|
+
before :all do
|
6
|
+
class TitledObject < ActiveFedora::Base
|
7
|
+
has_metadata 'foo', type: ActiveFedora::SimpleDatastream do |m|
|
8
|
+
m.field "title", :string
|
9
|
+
end
|
10
|
+
delegate :title, to: 'foo', multiple: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
after :all do
|
14
|
+
Object.send(:remove_const, :TitledObject)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "save" do
|
18
|
+
subject do
|
19
|
+
obj = TitledObject.create
|
20
|
+
obj.title = "Hydra for Dummies"
|
21
|
+
obj.save
|
22
|
+
obj
|
23
|
+
end
|
24
|
+
it "should keep a list of changes after a successful save" do
|
25
|
+
subject.previous_changes.should_not be_empty
|
26
|
+
subject.previous_changes.keys.should include("title")
|
27
|
+
end
|
28
|
+
it "should clean out changes" do
|
29
|
+
subject.title_changed?.should be_false
|
30
|
+
subject.changes.should be_empty
|
8
31
|
end
|
9
|
-
delegate :title, :to=>'foo', :unique=>true
|
10
32
|
end
|
11
|
-
end
|
12
|
-
after :all do
|
13
|
-
Object.send(:remove_const, :TitledObject)
|
14
33
|
end
|
15
34
|
|
16
|
-
describe "
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
35
|
+
describe "that only have a writer" do
|
36
|
+
before :all do
|
37
|
+
class TestDatastream < ActiveFedora::NtriplesRDFDatastream
|
38
|
+
# accepts_nested_attributes_for :title, would generate a method like this:
|
39
|
+
def title_attributes=(attributes)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
class TitledObject < ActiveFedora::Base
|
43
|
+
has_metadata 'foo', type: TestDatastream
|
44
|
+
delegate :title_attributes, to: 'foo', multiple: false
|
45
|
+
end
|
22
46
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
47
|
+
after :all do
|
48
|
+
Object.send(:remove_const, :TitledObject)
|
49
|
+
Object.send(:remove_const, :TestDatastream)
|
26
50
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
51
|
+
|
52
|
+
subject { TitledObject.new }
|
53
|
+
|
54
|
+
it "Should delegate the method" do
|
55
|
+
subject.title_attributes = {'0' => {'title' => 'Hello'}}
|
30
56
|
end
|
57
|
+
|
31
58
|
end
|
32
59
|
end
|
@@ -161,7 +161,7 @@ describe ActiveFedora::OmDatastream do
|
|
161
161
|
@obj.reload
|
162
162
|
end
|
163
163
|
it "should solrize terms with :type=>'date' to *_dt solr terms" do
|
164
|
-
@obj.to_solr[ActiveFedora::SolrService.solr_name('
|
164
|
+
@obj.to_solr[ActiveFedora::SolrService.solr_name('journal_issue_publication_date', type: :date)].should == ['2012-11-02T00:00:00Z']
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
data/spec/unit/query_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe ActiveFedora::Base do
|
|
20
20
|
it 'should notify of deprecation if no cast parameter is passed' do
|
21
21
|
Deprecation.should_receive(:warn).at_least(1).times
|
22
22
|
expect {
|
23
|
-
ActiveFedora::Base.find_one('
|
23
|
+
ActiveFedora::Base.find_one('mypid:99999')
|
24
24
|
}.to raise_error(ActiveFedora::ObjectNotFoundError)
|
25
25
|
end
|
26
26
|
end
|
@@ -28,7 +28,7 @@ describe ActiveFedora::Base do
|
|
28
28
|
it 'should not have a deprecation warning when no cast parameter is passed' do
|
29
29
|
Deprecation.should_not_receive(:warn)
|
30
30
|
expect {
|
31
|
-
SpecModel::Basic.find_one('
|
31
|
+
SpecModel::Basic.find_one('mypid:99999')
|
32
32
|
}.to raise_error(ActiveFedora::ObjectNotFoundError)
|
33
33
|
end
|
34
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.6.
|
4
|
+
version: 6.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-10-
|
13
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsolr
|
@@ -555,7 +555,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
555
555
|
version: '0'
|
556
556
|
requirements: []
|
557
557
|
rubyforge_project:
|
558
|
-
rubygems_version: 2.0.
|
558
|
+
rubygems_version: 2.0.3
|
559
559
|
signing_key:
|
560
560
|
specification_version: 4
|
561
561
|
summary: A convenience libary for manipulating documents in the Fedora Repository.
|