acfs 0.50.0 → 1.0.0.dev.1.b297

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +13 -5
  2. data/CHANGELOG.md +0 -80
  3. data/README.md +9 -8
  4. data/acfs.gemspec +7 -7
  5. data/lib/acfs.rb +5 -7
  6. data/lib/acfs/adapter/base.rb +2 -0
  7. data/lib/acfs/adapter/typhoeus.rb +13 -17
  8. data/lib/acfs/collections/paginatable.rb +10 -10
  9. data/lib/acfs/configuration.rb +5 -4
  10. data/lib/acfs/errors.rb +9 -10
  11. data/lib/acfs/global.rb +7 -16
  12. data/lib/acfs/location.rb +11 -11
  13. data/lib/acfs/middleware/base.rb +2 -1
  14. data/lib/acfs/middleware/json_decoder.rb +16 -0
  15. data/lib/acfs/middleware/json_encoder.rb +20 -0
  16. data/lib/acfs/middleware/logger.rb +2 -0
  17. data/lib/acfs/middleware/msgpack_decoder.rb +26 -0
  18. data/lib/acfs/middleware/msgpack_encoder.rb +19 -0
  19. data/lib/acfs/middleware/print.rb +2 -0
  20. data/lib/acfs/operation.rb +5 -5
  21. data/lib/acfs/request.rb +4 -4
  22. data/lib/acfs/request/callbacks.rb +3 -2
  23. data/lib/acfs/resource.rb +2 -2
  24. data/lib/acfs/resource/attributes.rb +38 -11
  25. data/lib/acfs/resource/attributes/base.rb +19 -10
  26. data/lib/acfs/resource/attributes/boolean.rb +8 -10
  27. data/lib/acfs/resource/attributes/date_time.rb +9 -6
  28. data/lib/acfs/resource/attributes/float.rb +5 -11
  29. data/lib/acfs/resource/attributes/integer.rb +5 -7
  30. data/lib/acfs/resource/attributes/list.rb +6 -13
  31. data/lib/acfs/resource/attributes/string.rb +5 -3
  32. data/lib/acfs/resource/attributes/uuid.rb +17 -8
  33. data/lib/acfs/resource/dirty.rb +15 -3
  34. data/lib/acfs/resource/loadable.rb +1 -0
  35. data/lib/acfs/resource/locatable.rb +4 -0
  36. data/lib/acfs/resource/operational.rb +2 -0
  37. data/lib/acfs/resource/persistence.rb +17 -17
  38. data/lib/acfs/resource/query_methods.rb +7 -8
  39. data/lib/acfs/resource/service.rb +2 -0
  40. data/lib/acfs/resource/validation.rb +4 -4
  41. data/lib/acfs/response.rb +2 -1
  42. data/lib/acfs/response/formats.rb +3 -2
  43. data/lib/acfs/response/status.rb +5 -3
  44. data/lib/acfs/runner.rb +11 -21
  45. data/lib/acfs/service.rb +6 -4
  46. data/lib/acfs/service/middleware.rb +30 -20
  47. data/lib/acfs/singleton_resource.rb +2 -0
  48. data/lib/acfs/stub.rb +21 -30
  49. data/lib/acfs/util.rb +1 -1
  50. data/lib/acfs/version.rb +4 -6
  51. data/spec/acfs/adapter/typhoeus_spec.rb +4 -12
  52. data/spec/acfs/collection_spec.rb +33 -45
  53. data/spec/acfs/configuration_spec.rb +1 -9
  54. data/spec/acfs/global_spec.rb +3 -21
  55. data/spec/acfs/middleware/json_decoder_spec.rb +45 -0
  56. data/spec/acfs/middleware/msgpack_decoder_spec.rb +36 -0
  57. data/spec/acfs/request/callbacks_spec.rb +8 -8
  58. data/spec/acfs/request_spec.rb +5 -5
  59. data/spec/acfs/resource/attributes/boolean_spec.rb +9 -40
  60. data/spec/acfs/resource/attributes/date_time_spec.rb +35 -29
  61. data/spec/acfs/resource/attributes/float_spec.rb +9 -48
  62. data/spec/acfs/resource/attributes/list_spec.rb +19 -43
  63. data/spec/acfs/resource/attributes/uuid_spec.rb +54 -31
  64. data/spec/acfs/resource/attributes_spec.rb +31 -17
  65. data/spec/acfs/resource/locatable_spec.rb +2 -2
  66. data/spec/acfs/resource/persistance_spec.rb +34 -65
  67. data/spec/acfs/resource/query_methods_spec.rb +90 -97
  68. data/spec/acfs/resource/validation_spec.rb +5 -4
  69. data/spec/acfs/response/formats_spec.rb +4 -4
  70. data/spec/acfs/response/status_spec.rb +1 -1
  71. data/spec/acfs/runner_spec.rb +3 -28
  72. data/spec/acfs/service/middleware_spec.rb +20 -4
  73. data/spec/acfs/service_spec.rb +5 -3
  74. data/spec/acfs/singleton_resource_spec.rb +2 -1
  75. data/spec/acfs/stub_spec.rb +22 -137
  76. data/spec/acfs_spec.rb +19 -22
  77. data/spec/spec_helper.rb +2 -3
  78. data/spec/support/service.rb +6 -10
  79. data/spec/support/shared/find_callbacks.rb +7 -7
  80. metadata +36 -43
  81. data/lib/acfs/middleware/json.rb +0 -27
  82. data/lib/acfs/middleware/msgpack.rb +0 -30
  83. data/lib/acfs/middleware/serializer.rb +0 -39
  84. data/lib/acfs/resource/attributes/dict.rb +0 -37
  85. data/lib/acfs/service/middleware/stack.rb +0 -63
  86. data/spec/acfs/middleware/json_spec.rb +0 -63
  87. data/spec/acfs/middleware/msgpack_spec.rb +0 -60
  88. data/spec/acfs/operation_spec.rb +0 -10
  89. data/spec/acfs/resource/attributes/dict_spec.rb +0 -75
  90. data/spec/acfs/resource/attributes/integer_spec.rb +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 5f6205aca10d63d37898eecce39e239605fc0a4165d17a9ad994ead94e0037dd
4
- data.tar.gz: e1dac804253b61cabd8d5e9410784268c689771fedb9bdcad8c99a67e0b946ef
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTZhZGMyZGMzM2UzYjJmODU1MDU3NGU1MmVkYTQ5MTQxZDUwYTI5ZA==
5
+ data.tar.gz: !binary |-
6
+ NGZhODhiOTY5MTc5M2QxNDMxYjFmYjA3MjVmMTA4ZGM0OGZjZWJkYw==
5
7
  SHA512:
6
- metadata.gz: 150fd36e55507f600437fe65dc3d853379799b6f5afc30c0aaa9644e36d4e025fa3ced557569f6af9e8cbbb8e484ede41281cefac7ceaecda3d6957647e5b76b
7
- data.tar.gz: 206228583c974b3ef735d1cfb524938595856bd8741e481c80b331da1779839c4ab31073f34d615561d68f53955ea5f58c501c2d5208039522e5296233d002aa
8
+ metadata.gz: !binary |-
9
+ Y2JkMDFjOTE0NDhjOGJkNDY1ZjIwMjgwMDg1ZmY2ZDRmNzc5NTk2MDhlZDA0
10
+ MDU5OWJhY2I1MDUyNmQ0MjBjYWZmZjcwZDEwNTIwNWJlMmI2YjZjOWU1YTJk
11
+ ODU3YzQ3NjFkZjlkZDA3YTlhOWE1MmZlYjk4M2U3MTM3ZjBjZmI=
12
+ data.tar.gz: !binary |-
13
+ NjY3YWI3MGYzMGQxNTljZTNkYWQzMjYxMjcxYTlhNTcyODFmNDJhZjg5Yzk2
14
+ NjIxZmQyM2MwYTZkNTdmYWM1NTdiN2JkZjYwMzg5ZTYwMzIyODk3MzdiYzli
15
+ MzI0MDJjMDgzMDcwOWJjZTI2YWIyOGFhMWQ3ZTIxNTU3M2QyZWU=
@@ -1,85 +1,5 @@
1
1
  # Changelog
2
2
 
3
- ## 1.2.0
4
-
5
- * Add Rails 5.2 compatibility
6
-
7
- ## 1.1.1
8
-
9
- * `each_item`: Pass collection to provided block (#40)
10
-
11
- ## 1.1.0
12
-
13
- * Add support for Rails 5.1
14
-
15
- ## 1.0.1
16
-
17
- * Fix deprecation warnings when using ::Mime
18
-
19
- ## 1.0.0
20
-
21
- * Switch to first non-development major as it's long time used in production.
22
- * Fix NewRelic RPM inference with middleware stack inherited from `ActionDispatch::MiddlewareStack`.
23
-
24
- ## 0.48.0
25
-
26
- * Remove #attribute_types broke since f7e4109 (Sep 2013, v0.23)
27
- * Fix attribute inheritance on subclassing broken since commit 7cf1d11 (Apr 2014, v0.43)
28
-
29
- ## 0.47.0
30
-
31
- * Change blank value handling of dict and list type (0a12ef1)
32
-
33
- ## 0.46.0
34
-
35
- * Rework types system (#39)
36
-
37
- ## 0.45.0
38
-
39
- * Fetching multiple records (`find(ary)`) is stable now, but untested (#38)
40
- * Middleware stack is build on ActionDispatch::MiddlewareStack now
41
- * Deprecate legacy middleware names (xyEncoder, xyDecoder)
42
-
43
- ## 0.44.0
44
-
45
- * Add option to configure adapter creation and pass option to typhoeus adapter e.g.
46
- limiting concurrency.
47
-
48
- ## 0.43.2
49
-
50
- * add `total_count` for paginated collections
51
-
52
- ## 0.43.1
53
-
54
- * Fix `:with` condition matching on stubs
55
-
56
- ## 0.43.0
57
-
58
- * Remove `Acfs::Model` (inherit from `Acfs::Resource`)
59
- * Stub does only a partial match of `:with` attributes now
60
- * Allow blocks as stub `:return`s
61
-
62
- ## 0.42.0
63
-
64
- * Add simple dict attribute type
65
-
66
- ## 0.40.0
67
-
68
- * Change `Resource#persisted?` to return true if it is not new
69
-
70
- ## 0.39.1
71
-
72
- * Fix automatic path parameter handling for #destroy
73
-
74
- ## 0.39.0
75
-
76
- * Add new event acfs.operation.before_process
77
-
78
- ## 0.38.0
79
-
80
- * Allow middlewares to abort request processing
81
- * Allow middlewares to receive the request operation object (via the request)
82
-
83
3
  ## 0.37.0
84
4
 
85
5
  * Add Acfs.on
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Acfs - *API client for services*
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/acfs.svg)](http://badge.fury.io/rb/acfs)
4
- [![Build Status](http://img.shields.io/travis/jgraichen/acfs/master.svg)](https://travis-ci.org/jgraichen/acfs)
5
- [![Coverage Status](http://img.shields.io/coveralls/jgraichen/acfs/master.svg)](https://coveralls.io/r/jgraichen/acfs)
6
- [![Code Climate](http://img.shields.io/codeclimate/github/jgraichen/acfs.svg)](https://codeclimate.com/github/jgraichen/acfs)
7
- [![Dependency Status](http://img.shields.io/gemnasium/jgraichen/acfs.svg)](https://gemnasium.com/jgraichen/acfs)
8
- [![RubyDoc Documentation](http://img.shields.io/badge/rubydoc-here-blue.svg)](http://rubydoc.info/github/jgraichen/acfs/master/frames)
3
+ [![Gem Version](https://badge.fury.io/rb/acfs.png)](http://badge.fury.io/rb/acfs)
4
+ [![Build Status](https://travis-ci.org/jgraichen/acfs.png?branch=master)](https://travis-ci.org/jgraichen/acfs)
5
+ [![Coverage Status](https://coveralls.io/repos/jgraichen/acfs/badge.png?branch=master)](https://coveralls.io/r/jgraichen/acfs)
6
+ [![Code Climate](https://codeclimate.com/github/jgraichen/acfs.png)](https://codeclimate.com/github/jgraichen/acfs)
7
+ [![Dependency Status](https://gemnasium.com/jgraichen/acfs.png)](https://gemnasium.com/jgraichen/acfs)
8
+ [![RubyDoc Documentation](http://b.repl.ca/v1/rubydoc-here-blue.png)](http://rubydoc.info/github/jgraichen/acfs/master/frames)
9
9
 
10
10
  Acfs is a library to develop API client libraries for single services within a larger service oriented application.
11
11
 
@@ -250,8 +250,8 @@ it 'should find user number one' do
250
250
  expect(user.name).to be == 'John Smith'
251
251
  expect(user.age).to be == 32
252
252
 
253
- expect(@stub).to be_called
254
- expect(@stub).to_not be_called 5.times
253
+ expect(@stub).to has_called
254
+ expect(@stub).to_not have_called 5.times
255
255
  end
256
256
 
257
257
  it 'should not find user number two' do
@@ -313,6 +313,7 @@ Read [official guide][2] to see to to subscribe.
313
313
  * Reusing model definitions for generating responses?
314
314
  * Rails responders providing REST operations with integrated ETag,
315
315
  Modified Headers, conflict detection, ...
316
+ * Pagination? Filtering? (If service API provides such features.)
316
317
  * Documentation
317
318
 
318
319
  ## Contributing
@@ -8,23 +8,23 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Acfs::VERSION
9
9
  spec.authors = ['Jan Graichen']
10
10
  spec.email = %w(jg@altimos.de)
11
- spec.description = 'API Client For Services'
12
- spec.summary = 'An abstract API base client for service oriented application.'
11
+ spec.description = %q{API Client For Services}
12
+ spec.summary = %q{An abstract API base client for service oriented application.}
13
13
  spec.homepage = 'https://github.com/jgraichen/acfs'
14
14
  spec.license = 'MIT'
15
15
 
16
16
  spec.files = Dir['**/*'].grep(%r{^((bin|lib|test|spec|features)/|.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)})
17
- spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = %w(lib)
20
20
 
21
- spec.add_runtime_dependency 'activesupport', '>= 4.2'
22
- spec.add_runtime_dependency 'activemodel', '>= 4.2'
23
- spec.add_runtime_dependency 'actionpack', '>= 4.2'
21
+ spec.add_runtime_dependency 'activesupport', '>= 3.1'
22
+ spec.add_runtime_dependency 'activemodel', '>= 3.1'
23
+ spec.add_runtime_dependency 'actionpack', '>= 3.1'
24
24
  spec.add_runtime_dependency 'multi_json'
25
25
 
26
26
  # Bundle update w/o version resolves to 0.3.3 ...
27
- spec.add_runtime_dependency 'typhoeus', '~> 1.0'
27
+ spec.add_runtime_dependency 'typhoeus', '>= 0.6.5'
28
28
 
29
29
  spec.add_runtime_dependency 'rack'
30
30
 
@@ -30,16 +30,13 @@ module Acfs
30
30
  module Middleware
31
31
  extend ActiveSupport::Autoload
32
32
  require 'acfs/middleware/base'
33
- require 'acfs/middleware/serializer'
34
33
 
35
34
  autoload :Print
36
35
  autoload :Logger
37
- autoload :JSON
38
- autoload :JsonDecoder, 'acfs/middleware/json'
39
- autoload :JsonEncoder, 'acfs/middleware/json'
40
- autoload :MessagePack, 'acfs/middleware/msgpack'
41
- autoload :MessagePackDecoder, 'acfs/middleware/msgpack'
42
- autoload :MessagePackEncoder, 'acfs/middleware/msgpack'
36
+ autoload :JsonDecoder
37
+ autoload :MessagePackDecoder, 'acfs/middleware/msgpack_decoder'
38
+ autoload :JsonEncoder
39
+ autoload :MessagePackEncoder, 'acfs/middleware/msgpack_encoder'
43
40
  end
44
41
 
45
42
  module Adapter
@@ -47,3 +44,4 @@ module Acfs
47
44
  require 'acfs/adapter/typhoeus'
48
45
  end
49
46
  end
47
+
@@ -1,8 +1,10 @@
1
1
  module Acfs::Adapter
2
+
2
3
  # Base adapter handling operation queuing
3
4
  # and processing.
4
5
  #
5
6
  class Base
7
+
6
8
  # Start processing queued requests.
7
9
  #
8
10
  def start
@@ -2,12 +2,10 @@ require 'typhoeus'
2
2
 
3
3
  module Acfs
4
4
  module Adapter
5
+
5
6
  # Adapter for Typhoeus.
6
7
  #
7
8
  class Typhoeus < Base
8
- def initialize(**kwargs)
9
- @options = kwargs
10
- end
11
9
 
12
10
  def start
13
11
  hydra.run
@@ -16,7 +14,9 @@ module Acfs
16
14
  raise
17
15
  end
18
16
 
19
- delegate :abort, to: :hydra
17
+ def abort
18
+ hydra.abort
19
+ end
20
20
 
21
21
  def run(request)
22
22
  convert_request(request).run
@@ -26,21 +26,17 @@ module Acfs
26
26
  hydra.queue convert_request request
27
27
  end
28
28
 
29
- protected
30
-
29
+ protected
31
30
  def hydra
32
- @hydra ||= ::Typhoeus::Hydra.new(**@options)
31
+ @hydra ||= ::Typhoeus::Hydra.new
33
32
  end
34
33
 
35
34
  def convert_request(req)
36
35
  request = ::Typhoeus::Request.new req.url,
37
- method: req.method,
38
- params: req.params,
39
- headers: req.headers.merge(
40
- 'Expect' => '',
41
- 'Transfer-Encoding' => ''
42
- ),
43
- body: req.body
36
+ method: req.method,
37
+ params: req.params,
38
+ headers: req.headers,
39
+ body: req.body
44
40
 
45
41
  request.on_complete do |response|
46
42
  req.complete! convert_response(req, response)
@@ -51,9 +47,9 @@ module Acfs
51
47
 
52
48
  def convert_response(request, response)
53
49
  Acfs::Response.new request,
54
- status: response.code,
55
- headers: response.headers,
56
- body: response.body
50
+ status: response.code,
51
+ headers: response.headers,
52
+ body: response.body
57
53
  end
58
54
  end
59
55
  end
@@ -1,14 +1,15 @@
1
1
  module Acfs::Collections
2
+
2
3
  #
3
4
  module Paginatable
4
5
  extend ActiveSupport::Concern
5
6
 
6
7
  included do
7
- def self.operation(_action, opts = {}, &_block)
8
+ def self.operation(action, opts = {}, &block)
8
9
  opts[:url]
9
10
  end
10
11
 
11
- attr_reader :total_pages, :current_page, :total_count
12
+ attr_reader :total_pages, :current_page
12
13
  end
13
14
 
14
15
  def process_response(response)
@@ -33,9 +34,12 @@ module Acfs::Collections
33
34
  end
34
35
 
35
36
  def page(rel, &block)
36
- return unless relations[rel]
37
-
38
- @resource_class.all nil, url: relations[rel], &block
37
+ if relations[rel]
38
+ @resource_class.all nil, url: relations[rel], &block
39
+ else
40
+ # raise ArgumentError.new "No relative page `#{rel}'."
41
+ nil
42
+ end
39
43
  end
40
44
 
41
45
  private
@@ -49,17 +53,13 @@ module Acfs::Collections
49
53
  @total_pages = Integer(headers['X-Total-Pages'])
50
54
  end
51
55
 
52
- if headers['X-Total-Count']
53
- @total_count = Integer(headers['X-Total-Count'])
54
- end
55
-
56
56
  setup_links headers['Link'] if headers['Link']
57
57
  end
58
58
 
59
59
  def setup_links(links)
60
60
  links.split(/,\s+/).each do |link|
61
61
  if link =~ /^\s*<([^>]+)>.*\s+rel="([\w_-]+)".*$/
62
- relations[Regexp.last_match[2]] = Regexp.last_match[1]
62
+ relations[$2] = $1
63
63
  end
64
64
  end
65
65
  end
@@ -2,11 +2,11 @@ require 'uri'
2
2
  require 'yaml'
3
3
 
4
4
  module Acfs
5
+
5
6
  # Acfs configuration is used to locate services and get their base URLs.
6
7
  #
7
8
  class Configuration
8
9
  attr_reader :locations
9
- attr_accessor :adapter
10
10
 
11
11
  # @api private
12
12
  def initialize
@@ -28,7 +28,7 @@ module Acfs
28
28
  if block.arity > 0
29
29
  block.call self
30
30
  else
31
- instance_eval(&block)
31
+ instance_eval &block
32
32
  end
33
33
  end
34
34
 
@@ -64,10 +64,10 @@ module Acfs
64
64
  # @return [undefined]
65
65
  #
66
66
  def load(filename)
67
- config = YAML.load File.read filename
67
+ config = YAML::load File.read filename
68
68
  env = ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
69
69
 
70
- config = config[env] if config.key? env
70
+ config = config[env] if config.has_key? env
71
71
  config.each do |key, value|
72
72
  case key
73
73
  when 'services' then load_services value
@@ -88,6 +88,7 @@ module Acfs
88
88
  end
89
89
 
90
90
  class << self
91
+
91
92
  # @api private
92
93
  #
93
94
  # Return current configuration object.
@@ -1,4 +1,5 @@
1
1
  module Acfs
2
+
2
3
  # Acfs base error.
3
4
  #
4
5
  class Error < StandardError
@@ -22,20 +23,20 @@ module Acfs
22
23
  message << ": #{response.code}"
23
24
  if response.data
24
25
  message << "\n with content:\n "
25
- message << response.data.map {|k, v| "#{k.inspect}: #{v.inspect}" }.join("\n ")
26
+ message << response.data.map{|k,v| "#{k.inspect}: #{v.inspect}"}.join("\n ")
26
27
  end
27
28
  if response.headers.any?
28
29
  message << "\n with headers:\n "
29
- message << response.headers.map {|k, v| "#{k}: #{v}" }.join("\n ")
30
+ message << response.headers.map{|k,v| "#{k}: #{v}"}.join("\n ")
30
31
  end
31
32
  message << "\nbased on request: #{response.request.method.upcase} #{response.request.url} #{response.request.format}"
32
33
  if response.request.data
33
34
  message << "\n with content:\n "
34
- message << response.request.data.map {|k, v| "#{k.inspect}: #{v.inspect}" }.join("\n ")
35
+ message << response.request.data.map{|k,v| "#{k.inspect}: #{v.inspect}"}.join("\n ")
35
36
  end
36
37
  if response.request.headers.any?
37
38
  message << "\n with headers:\n "
38
- message << response.request.headers.map {|k, v| "#{k}: #{v}" }.join("\n ")
39
+ message << response.request.headers.map{|k,v| "#{k}: #{v}"}.join("\n ")
39
40
  end
40
41
  end
41
42
  super opts, message
@@ -46,14 +47,12 @@ module Acfs
46
47
  attr_reader :stubs, :operation
47
48
 
48
49
  def initialize(opts = {})
49
- require 'pp'
50
-
51
50
  @stubs = opts.delete :stubs
52
51
  @operation = opts.delete :operation
53
52
 
54
- super opts, "Ambiguous stubs for #{operation.action} on #{operation.resource}.\n" +
55
- stubs.map {|s| " #{s.opts.pretty_inspect}" }.join
53
+ super opts, 'Ambiguous stubs.'
56
54
  end
55
+
57
56
  end
58
57
 
59
58
  # Resource not found error raised on a 404 response
@@ -68,7 +67,7 @@ module Acfs
68
67
  def initialize(opts = {})
69
68
  @errors = opts.delete :errors
70
69
  @resource = opts.delete :resource
71
- opts[:message] ||= @errors.map {|k, v| "#{k}: #{v.join ', '}" }.join ', ' if @errors.is_a? Hash
70
+ opts[:message] ||= @errors.map{ |k,v| "#{k}: #{v.join ', '}" }.join ', ' if @errors.is_a? Hash
72
71
  opts[:message] ||= @errors.join ', ' if @errors.is_a? Array
73
72
  super
74
73
  end
@@ -100,7 +99,7 @@ module Acfs
100
99
  def initialize(opts = {})
101
100
  @base_class = opts.delete :base_class
102
101
  @type_name = opts.delete :type_name
103
- opts[:message] = "Received resource type `#{type_name}` is no subclass of #{base_class}"
102
+ opts[:message] = "Recieved ressource type `#{type_name}` is no subclass of #{base_class}"
104
103
  super
105
104
  end
106
105
  end
@@ -1,22 +1,14 @@
1
1
  module Acfs
2
- #
2
+
3
3
  # Global Acfs module methods.
4
4
  #
5
5
  module Global
6
- #
6
+
7
7
  # @api private
8
8
  # @return [Runner]
9
9
  #
10
10
  def runner
11
- Thread.current[:acfs_runner] ||= begin
12
- adapter = Configuration.current.adapter
13
-
14
- if adapter
15
- Runner.new adapter.call
16
- else
17
- Runner.new Adapter::Typhoeus.new
18
- end
19
- end
11
+ @runner ||= Runner.new Adapter::Typhoeus.new
20
12
  end
21
13
 
22
14
  # @api public
@@ -67,10 +59,9 @@ module Acfs
67
59
  # Acfs.add_callback(user, &callback_two)
68
60
  #
69
61
  def add_callback(resource, &block)
70
- unless resource.respond_to?(:__callbacks__)
71
- raise ArgumentError.new 'Given resource is not an Acfs resource ' \
72
- "delegator but a: #{resource.class.name}"
73
- end
62
+ raise ArgumentError.new "Given resource is not an Acfs resource but "\
63
+ "a: #{resource.class.name}" \
64
+ unless resource.respond_to?(:__callbacks__)
74
65
  return false if block.nil?
75
66
 
76
67
  if resource.loaded?
@@ -82,7 +73,7 @@ module Acfs
82
73
 
83
74
  def on(*resources)
84
75
  resources.each do |resource|
85
- add_callback resource do |_|
76
+ add_callback resource do |ret|
86
77
  yield(*resources) unless resources.any? {|res| !res.loaded? }
87
78
  end
88
79
  end