active-fedora 9.0.0.beta5 → 9.0.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17554700da06c7fc155b4336f11cc269e1114d42
4
- data.tar.gz: 85dc2454b14e8a65334524debae01d56c690c712
3
+ metadata.gz: d8fb1d0fea1b50349e3da9a6cb685e3865fcb716
4
+ data.tar.gz: 518c8edc13fd3a87ef09c7022eee3d6a29c2ddb0
5
5
  SHA512:
6
- metadata.gz: 94d352731c92f119bc6b7ec521dcead14a68099588c840874dece0f38c27e47b29e45ee063bd010df1bf7624161b302b57d958ee29c7c66ec241eef8a8b4b7ce
7
- data.tar.gz: 3cdf222ffa305dc0f452ddbfb8008a8a628ec7a222f969c52f043fd3ffc4506042a4c84f1908065b74c30d190ef1c18f2dae1bf9e0ba8c71197d023e4d68acb3
6
+ metadata.gz: 5c0bce8730af54df688fc1a3c0d5f41bc7df148070b21bfbeb81246c7766f650d73abf12b70deb3cefc415e40d416fb31c7856808705be923886334ced6200de
7
+ data.tar.gz: f6467c70c153178f4c190a42d084727093b57387fe571d8a33722ca3bfea90b5ef4d2f9dd043ccac253e6ec8cef808889c255f31a6fe6bc37af0e1f732f40201
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency 'om', '~> 3.1'
19
19
  s.add_dependency 'nom-xml', '>= 0.5.1'
20
20
  s.add_dependency "activesupport", '>= 4.1.0'
21
- s.add_dependency "active-triples", '~> 0.4.0'
21
+ s.add_dependency "active-triples", '~> 0.5.0'
22
22
  s.add_dependency "rdf-rdfxml", '~> 1.1.0'
23
23
  s.add_dependency "linkeddata"
24
24
  s.add_dependency "deprecation"
@@ -123,6 +123,7 @@ module ActiveFedora #:nodoc:
123
123
  autoload :Serializers
124
124
  autoload :PrimaryKey
125
125
  autoload :PropertyBuilder
126
+ autoload :NodeConfig
126
127
  end
127
128
  end
128
129
 
@@ -169,10 +169,10 @@ module ActiveFedora
169
169
  end
170
170
 
171
171
  def property name, properties={}, &block
172
- find_or_create_defined_attribute(name, nil, {multiple: true}.merge(properties))
172
+ properties = { multiple: true }.merge(properties)
173
+ find_or_create_defined_attribute(name, nil, properties)
173
174
  raise ArgumentError, "#{name} is a keyword and not an acceptable property name." if protected_property_name? name
174
- properties = properties.merge(multivalue: false) if properties[:multiple] == false
175
- reflection = ActiveFedora::Attributes::PropertyBuilder.build(self, name, properties.except(:multiple), &block)
175
+ reflection = ActiveFedora::Attributes::PropertyBuilder.build(self, name, properties, &block)
176
176
  # reflection = ActiveTriple::PropertyBuilder.build(self, name, properties, &block)
177
177
  ActiveTriples::Reflection.add_reflection self, name, reflection
178
178
  end
@@ -0,0 +1,13 @@
1
+ module ActiveFedora::Attributes
2
+ class NodeConfig < ActiveTriples::NodeConfig
3
+ def multiple?
4
+ @multiple
5
+ end
6
+
7
+ def initialize(term, predicate, options={})
8
+ super
9
+ @multiple = options[:multiple]
10
+ end
11
+
12
+ end
13
+ end
@@ -4,8 +4,13 @@ module ActiveFedora::Attributes
4
4
  def self.define_accessors(model, reflection)
5
5
  mixin = model.generated_property_methods
6
6
  name = reflection.term
7
- define_readers(mixin, name)
8
- reflection.multivalue ? define_writers(mixin, name) : define_singular_writers(mixin, name)
7
+ if reflection.multiple?
8
+ define_readers(mixin, name)
9
+ define_writers(mixin, name)
10
+ else
11
+ define_singular_readers(mixin, name)
12
+ define_singular_writers(mixin, name)
13
+ end
9
14
  end
10
15
 
11
16
  def self.define_writers(mixin, name)
@@ -19,6 +24,14 @@ module ActiveFedora::Attributes
19
24
  CODE
20
25
  end
21
26
 
27
+ def self.define_singular_readers(mixin, name)
28
+ mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
29
+ def #{name}(*args)
30
+ get_values(:#{name}).first
31
+ end
32
+ CODE
33
+ end
34
+
22
35
  def self.define_singular_writers(mixin, name)
23
36
  mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
24
37
  def #{name}=(value)
@@ -29,5 +42,11 @@ module ActiveFedora::Attributes
29
42
  end
30
43
  CODE
31
44
  end
45
+
46
+ def build(&block)
47
+ NodeConfig.new(name, options[:predicate], options.except(:predicate)) do |config|
48
+ config.with_index(&block) if block_given?
49
+ end
50
+ end
32
51
  end
33
52
  end
@@ -66,8 +66,7 @@ module ActiveFedora
66
66
  klass.properties.merge(self.properties).each do |property, config|
67
67
  klass.property(config.term,
68
68
  predicate: config.predicate,
69
- class_name: config.class_name,
70
- multivalue: config.multivalue)
69
+ class_name: config.class_name)
71
70
  end
72
71
  klass
73
72
  end
@@ -43,7 +43,7 @@ module ActiveFedora
43
43
  # It is expected that the singular filter gets applied after fetching the value from this
44
44
  # resource, so cast everything back to an array.
45
45
  def set_value(k, v)
46
- @hash[k] = v
46
+ @hash[k] = Array(v)
47
47
  end
48
48
 
49
49
  def get_values(k)
@@ -102,8 +102,7 @@ module ActiveFedora
102
102
  klass.properties.merge(self.class.properties).each do |prop, config|
103
103
  klass.property(config.term,
104
104
  predicate: config.predicate,
105
- class_name: config.class_name,
106
- multivalue: config.multivalue)
105
+ class_name: config.class_name)
107
106
  end
108
107
  klass.accepts_nested_attributes_for(*nested_attributes_options.keys) unless nested_attributes_options.blank?
109
108
  uri_stub = self.class.rdf_subject.call(self)
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "9.0.0.beta5"
2
+ VERSION = "9.0.0.beta6"
3
3
  end
@@ -12,7 +12,7 @@ describe ActiveFedora::RDFDatastream do
12
12
  before do
13
13
  class MyDatastream < ActiveFedora::NtriplesRDFDatastream
14
14
  property :title, predicate: ::RDF::DC.title
15
- property :description, predicate: ::RDF::DC.description, :multivalue => false
15
+ property :description, predicate: ::RDF::DC.description
16
16
  end
17
17
  class MyObj < ActiveFedora::Base
18
18
  has_metadata 'descMetadata', type: MyDatastream
@@ -39,13 +39,6 @@ describe ActiveFedora::RDFDatastream do
39
39
  expect(subject.title).to eq ['']
40
40
  end
41
41
 
42
- describe "when multivalue: false" do
43
- it "should return single values" do
44
- subject.description = 'my description'
45
- expect(subject.description).to eq 'my description'
46
- end
47
- end
48
-
49
42
  it "should clear stuff" do
50
43
  subject.title = ['one', 'two', 'three']
51
44
  subject.title.clear
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: 9.0.0.beta5
4
+ version: 9.0.0.beta6
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: 2014-12-06 00:00:00.000000000 Z
13
+ date: 2014-12-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rsolr
@@ -74,14 +74,14 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: 0.4.0
77
+ version: 0.5.0
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: 0.4.0
84
+ version: 0.5.0
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rdf-rdfxml
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -312,6 +312,7 @@ files:
312
312
  - lib/active_fedora/attribute_methods/read.rb
313
313
  - lib/active_fedora/attribute_methods/write.rb
314
314
  - lib/active_fedora/attributes.rb
315
+ - lib/active_fedora/attributes/node_config.rb
315
316
  - lib/active_fedora/attributes/primary_key.rb
316
317
  - lib/active_fedora/attributes/property_builder.rb
317
318
  - lib/active_fedora/attributes/serializers.rb