acfs 0.32.1.1.b274 → 0.32.1.1.b275
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 +8 -8
- data/CHANGELOG.md +4 -0
- data/lib/acfs/model/attributes.rb +10 -0
- data/lib/acfs/model/query_methods.rb +1 -1
- data/spec/acfs/model/attributes_spec.rb +30 -7
- data/spec/spec_helper.rb +0 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGZmNGMyYTFkNTc3MDVlNzE2OTYxN2FkZjI5YmFiYzFlZTIyMWIwNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGFhMTlhN2U0MmY5NDZlZDhiYzk2ZmI1MTliY2I3MjM0OGNkY2IxMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzMyNDkzYTI4YTE5MzRkYTY0NWEzMjUwNThhYzliZjc1ZWMzNDYwNWE3N2E2
|
10
|
+
Njg3YWY4NWU2OTNlNzk4MDNmNWQ1ZjdjNGM5MTE3ZmRhYjIwYTM3NDJlNWRi
|
11
|
+
NzRkZjA0ZjU4OTRmMjdiMWYxOGNkNmYyOTMxMWU3YmNjNWUyOGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDllMTVmMjU2ZmE5NjQwOGQxNWU4MGIyMTI5Yjg0ZDg4NWZmZDUxYmM1NWY3
|
14
|
+
YTM5Mjc1ZTFhMDVlNTU1ZTRmOGQ4OWVlMDFkZDg3ZWJiZDFjMmI2NzBlODhj
|
15
|
+
MDIwZjM5MGI5ZWQzOGU3MmFiOWFkMjBmZmFkYTM1YzkwNzZjMzc=
|
data/CHANGELOG.md
CHANGED
@@ -98,6 +98,16 @@ module Acfs::Model
|
|
98
98
|
def write_attributes(attributes, opts = {})
|
99
99
|
return false unless attributes.respond_to? :each
|
100
100
|
|
101
|
+
if opts.fetch(:unknown,:ignore) == :raise
|
102
|
+
if (attributes.keys.map(&:to_s) - self.class.attributes.keys).any?
|
103
|
+
raise ArgumentError.new "Unknown attributes: #{(attributes.keys - self.class.attributes.keys).map(&:inspect).join(', ')}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
attributes = attributes.select do |k, v|
|
108
|
+
self.class.attributes.keys.include? k.to_s
|
109
|
+
end
|
110
|
+
|
101
111
|
procs = {}
|
102
112
|
|
103
113
|
attributes.each do |key, _|
|
@@ -42,19 +42,42 @@ describe Acfs::Model::Attributes do
|
|
42
42
|
model.attribute :name, :string, default: 'John'
|
43
43
|
model.attribute :age, :integer, default: 25
|
44
44
|
end
|
45
|
+
let(:args) { [params] }
|
46
|
+
let(:params){ {name: 'James'} }
|
45
47
|
let(:m) { model.new }
|
48
|
+
let(:action) { lambda{ m.write_attributes *args } }
|
49
|
+
subject { action }
|
46
50
|
|
47
|
-
it 'should update attributes'
|
48
|
-
m
|
51
|
+
it 'should update attributes' do
|
52
|
+
should change(m, :attributes)
|
53
|
+
.from({'name' => 'John', 'age' => 25})
|
54
|
+
.to({'name' => 'James', 'age' => 25})
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'without non-hash params' do
|
58
|
+
let(:params) { 'James' }
|
49
59
|
|
50
|
-
|
60
|
+
it { should_not change(m, :attributes) }
|
61
|
+
its(:call) { should eq false }
|
51
62
|
end
|
52
63
|
|
53
|
-
|
54
|
-
|
64
|
+
context 'with unknown attributes' do
|
65
|
+
let(:params) { {name: 'James', born_at: Time.now} }
|
55
66
|
|
56
|
-
|
57
|
-
|
67
|
+
it { should_not raise_error }
|
68
|
+
|
69
|
+
it 'should update known attributes' do
|
70
|
+
should change(m, :attributes)
|
71
|
+
.from({'name' => 'John', 'age' => 25})
|
72
|
+
.to({'name' => 'James', 'age' => 25})
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'with unknown: :raise option' do
|
76
|
+
let(:args) { [params, {unknown: :raise}] }
|
77
|
+
|
78
|
+
it { should raise_error(ArgumentError, /unknown attribute/i) }
|
79
|
+
it { expect{ subject.call rescue true }.to_not change(m, :attributes) }
|
80
|
+
end
|
58
81
|
end
|
59
82
|
end
|
60
83
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.32.1.1.
|
4
|
+
version: 0.32.1.1.b275
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|