acfs 0.9.0 → 0.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1bfc6cac043fef9d28d10c28ed7c4ad25e8ed22
4
- data.tar.gz: 2c5a99cfc3a1d02bfc5ea0012f71b8d5a904ff17
3
+ metadata.gz: 9983fabc6b3c91e17cf08ac15da6e51aecf584b5
4
+ data.tar.gz: 53f6525a13c507bd7cac8132d2618a2b92e551ca
5
5
  SHA512:
6
- metadata.gz: 3a142008f5361b14a32070cd42d63353ef31f63a75b78101b0584f67f9f903a2aeeb8cf9886ae215e9831fe36e0e322ebb71e9a555a832bcf65184c1751685d0
7
- data.tar.gz: 193516f56822194e967ac7048e04c85c311a8e5ebc7aaf9074ee853392b98dd3237d2b0444b786a91c3cfb35343fc7a15b2e4054b37761cc655801ea793a0496
6
+ metadata.gz: 7869d4338121f188461dd2e2b4383f1175ebec3255e868a36cd53c63df31cbf6bb746135c8aaddebefb3f3ec5185e565606330a23ebcd75f3f4f838a94ec3591
7
+ data.tar.gz: d9c7a0575f86fd9e2b71fc98336166aef3e770e82fe6c7f5365b7751eeee78a987fa8eb433b326e228ceccc62c2daba610268664594b5992127911676f5aa735
data/README.md CHANGED
@@ -13,7 +13,7 @@ level and automatic request queuing and parallel processing. See Usage for more.
13
13
 
14
14
  Add this line to your application's Gemfile:
15
15
 
16
- gem 'acfs', '~> 0.9.0'
16
+ gem 'acfs', '~> 0.10.0'
17
17
 
18
18
  **Note:** Acfs is under development. I'll try to avoid changes to the public
19
19
  API but internal APIs may change quite often.
@@ -33,7 +33,7 @@ module Acfs::Model
33
33
  # user.attributes # => { "name" => "John" }
34
34
  #
35
35
  def attributes
36
- self.class.attributes.keys.inject({}) { |h, k| h[k.to_s] = public_send k; h }
36
+ HashWithIndifferentAccess.new self.class.attributes.keys.inject({}) { |h, k| h[k.to_sym] = public_send k; h }
37
37
  end
38
38
 
39
39
  # Update all attributes with given hash.
@@ -51,6 +51,8 @@ module Acfs::Model
51
51
  # Write a hash of attributes and values.
52
52
  #
53
53
  def write_attributes(attributes, opts = {})
54
+ return false unless attributes.respond_to? :each
55
+
54
56
  procs = {}
55
57
 
56
58
  attributes.each do |key, _|
@@ -64,6 +66,7 @@ module Acfs::Model
64
66
  procs.each do |key, proc|
65
67
  write_attribute key, instance_exec(&proc), opts
66
68
  end
69
+ true
67
70
  end
68
71
 
69
72
  # Write an attribute.
@@ -1,7 +1,7 @@
1
1
  module Acfs
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 9
4
+ MINOR = 10
5
5
  PATCH = 0
6
6
  STAGE = nil
7
7
 
@@ -7,7 +7,7 @@ describe Acfs::Model::Attributes do
7
7
  before { model.attribute :name, :string, default: 'John' }
8
8
 
9
9
  it 'should have attribute list' do
10
- expect(model.new.attributes).to include('name')
10
+ expect(model.new.attributes).to include(:name)
11
11
  end
12
12
 
13
13
  it 'should set default attributes' do
@@ -33,10 +33,28 @@ describe Acfs::Model::Attributes do
33
33
  end
34
34
 
35
35
  it 'should return hash of all attributes' do
36
- expect(model.new.attributes).to be == {
37
- 'name' => 'John',
38
- 'age' => 25
39
- }
36
+ expect(model.new.attributes).to be == { name: 'John', age: 25 }.stringify_keys
37
+ end
38
+ end
39
+
40
+ describe '#write_attributes' do
41
+ before do
42
+ model.attribute :name, :string, default: 'John'
43
+ model.attribute :age, :integer, default: 25
44
+ end
45
+ let(:m) { model.new }
46
+
47
+ it 'should update attributes' do
48
+ m.write_attributes name: 'James'
49
+
50
+ expect(m.attributes).to be == { name: 'James', age: 25 }.stringify_keys
51
+ end
52
+
53
+ it 'should do nothing on non-array types' do
54
+ ret = m.write_attributes 'James'
55
+
56
+ expect(ret).to be_false
57
+ expect(m.attributes).to be == { name: 'John', age: 25 }.stringify_keys
40
58
  end
41
59
  end
42
60
 
@@ -28,7 +28,7 @@ describe "Acfs" do
28
28
  stub = stub_request(:put, "http://users.example.org/users/2")
29
29
  .to_return { |request| { body: request.body, headers: {'Content-Type' => request.headers['Content-Type']}} }
30
30
 
31
- @user = MyUser.find(2)
31
+ @user = MyUser.find 2
32
32
  Acfs.run
33
33
 
34
34
  expect(@user).to_not be_changed
@@ -133,6 +133,7 @@ describe "Acfs" do
133
133
 
134
134
  it 'should load associated resources from different service' do
135
135
  @user = MyUser.find 2 do |user|
136
+ expect(user.id).to be == 2
136
137
  @comments = Comment.where user: user.id
137
138
  end
138
139
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen