resource_manager 0.0.4 → 0.0.5

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: 889d565e3adc71321786d04a1ee9ab5adb4a0f6d
4
- data.tar.gz: f8aeb3332f592fea72114099f6519be4622b0626
3
+ metadata.gz: ff1ede6e2576d28ac901de727a9822b69b763087
4
+ data.tar.gz: 568c1a0621b8af33bbcba4dc97531449c8ce487c
5
5
  SHA512:
6
- metadata.gz: e0a24a5aad021e72791cfdd6a7f0318fe8666e6811ef116c45f85c73b33f9ac4b1fee2f78ee948af7a4246aa45df2a3fc06a4253cc43f9f4a9b97d05b948ad9f
7
- data.tar.gz: 795ef835e288504590ad1508c4930d9ca84d28372a1b4a99ca88295ecec4f4320162ab3138215cdd38e7d331d257965fe6b55d0e997793f057d4e79b08764554
6
+ metadata.gz: 5de03bf7c82f827672d667e066f734d7c1ed998c995bc2cb40457f202d1c8632e6c4be85b8e114cbf4dd5dcb5698a3aa4efcb5e4f231b36090f1febf0dcecdb5
7
+ data.tar.gz: 09258a64969fbad4b282dbbe04226e698ead60933e6c0deb0ba8cd4eb6265672e2416b0b9380b44be0d7f83d754b1cfd5487e9da72d9f379bff3ab57c2a981e4
@@ -1,3 +1,3 @@
1
1
  module ResourceManager
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -34,7 +34,7 @@ module ResourceManager
34
34
  end
35
35
 
36
36
  ['', '!'].each do |name|
37
- define_method "create#{name}" do |params|
37
+ define_method "create#{name}" do |params, &block|
38
38
  transaction do
39
39
  run_callback(:before_create, params)
40
40
 
@@ -43,7 +43,7 @@ module ResourceManager
43
43
  else
44
44
  item = model.new(params)
45
45
  saved = item.send("save#{name}")
46
- yield(item, saved) if block_given?
46
+ block.call(item, saved) if block.present?
47
47
  item
48
48
  end
49
49
 
@@ -52,7 +52,7 @@ module ResourceManager
52
52
  end
53
53
  end
54
54
 
55
- define_method "update#{name}" do |item_or_id, params|
55
+ define_method "update#{name}" do |item_or_id, params, &block|
56
56
  transaction do
57
57
  item = item(item_or_id)
58
58
  run_callback(:before_update, item, params)
@@ -63,7 +63,7 @@ module ResourceManager
63
63
  item.assign_attributes(params)
64
64
  changed = item.changed
65
65
  saved = item.send("save#{name}")
66
- yield(item, saved) if block_given?
66
+ block.call(item, saved) if block.present?
67
67
  item
68
68
  end
69
69
 
@@ -61,12 +61,18 @@ describe ResourceManager::Base do
61
61
  expect(result_item).to be_nil
62
62
  end
63
63
 
64
- it 'yields block' do
65
- manager.create({test: 1}) do |item, result|
66
- expect(item).to be_a_kind_of(Model)
67
- expect(result).to be_falsey
68
- end
64
+
65
+ end
66
+
67
+ it 'yields block' do
68
+ _item = nil
69
+ _result = nil
70
+ manager.create({test: 1}) do |item, result|
71
+ _item = item
72
+ _result = result
69
73
  end
74
+ expect(_item).to be_a_kind_of(Model)
75
+ expect(_result).to be_truthy
70
76
  end
71
77
  end
72
78
 
@@ -120,10 +126,16 @@ describe ResourceManager::Base do
120
126
  end
121
127
 
122
128
  it 'yields block' do
129
+ _item = nil
130
+ _result = nil
131
+
123
132
  manager.update(1, {test: 1}) do |item, result|
124
- expect(item).to be_a_kind_of(Model)
125
- expect(result).to be_truthy
133
+ _item = item
134
+ _result = result
126
135
  end
136
+
137
+ expect(_item).to be_a_kind_of(Model)
138
+ expect(_result).to be_truthy
127
139
  end
128
140
 
129
141
  context 'with failed saving' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-02 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler