restafari 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,8 +27,8 @@ module Restafari
27
27
 
28
28
  default_params ||= {}
29
29
 
30
- define_singleton_method(name) do |params={}|
31
- execute!(path, default_params.merge(params))
30
+ define_singleton_method(name) do |params={}, &block|
31
+ execute!(path, default_params.merge(params), &block)
32
32
  end
33
33
 
34
34
  define_singleton_method("#{name}_url") do |params={}|
@@ -41,11 +41,12 @@ module Restafari
41
41
  end
42
42
 
43
43
  private
44
- def execute!(path, params)
44
+ def execute!(path, params, &block)
45
45
  conn = Faraday.new(url: Restafari.config.url)
46
46
  Restafari.config.run_before_request_hook(params)
47
47
  result = conn.send(Restafari.config.http_method, path, params) do |req|
48
48
  @req = req
49
+ yield req if block_given?
49
50
  end
50
51
  result.env[:req] = Hash[@req.each_pair.to_a]
51
52
  Restafari.config.run_after_response_hook(result)
@@ -1,3 +1,3 @@
1
1
  module Restafari
2
- VERSION = "0.7.3"
2
+ VERSION = "0.7.4"
3
3
  end
@@ -61,4 +61,18 @@ describe Restafari::Action do
61
61
  UrlTest.url_method_url(rt:2).to_s.should eq "http://www.example.com/url_method?rt=2"
62
62
  end
63
63
 
64
+ it "should allow passing block to actions" do
65
+ class SomeAction
66
+ include Restafari::Action
67
+ action :some_method
68
+ end
69
+
70
+ SomeAction.some_method() do |req|
71
+ @req = req
72
+ end
73
+ @req.should be_kind_of(Faraday::Request)
74
+
75
+
76
+ end
77
+
64
78
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restafari
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 3
10
- version: 0.7.3
9
+ - 4
10
+ version: 0.7.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Danni Friedland
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-18 00:00:00 Z
18
+ date: 2012-08-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: faraday