grape 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -4
  3. data/README.md +144 -4
  4. data/grape.gemspec +3 -1
  5. data/lib/grape.rb +94 -66
  6. data/lib/grape/api.rb +46 -4
  7. data/lib/grape/api/instance.rb +23 -12
  8. data/lib/grape/dsl/desc.rb +11 -2
  9. data/lib/grape/dsl/validations.rb +4 -3
  10. data/lib/grape/eager_load.rb +18 -0
  11. data/lib/grape/endpoint.rb +3 -3
  12. data/lib/grape/error_formatter.rb +1 -1
  13. data/lib/grape/exceptions/validation_errors.rb +4 -2
  14. data/lib/grape/formatter.rb +1 -1
  15. data/lib/grape/middleware/auth/base.rb +2 -4
  16. data/lib/grape/middleware/base.rb +2 -0
  17. data/lib/grape/middleware/helpers.rb +10 -0
  18. data/lib/grape/parser.rb +1 -1
  19. data/lib/grape/util/base_inheritable.rb +34 -0
  20. data/lib/grape/util/inheritable_values.rb +5 -25
  21. data/lib/grape/util/lazy_block.rb +25 -0
  22. data/lib/grape/util/lazy_value.rb +5 -0
  23. data/lib/grape/util/reverse_stackable_values.rb +7 -36
  24. data/lib/grape/util/stackable_values.rb +19 -22
  25. data/lib/grape/validations/attributes_iterator.rb +5 -3
  26. data/lib/grape/validations/multiple_attributes_iterator.rb +11 -0
  27. data/lib/grape/validations/params_scope.rb +12 -12
  28. data/lib/grape/validations/single_attribute_iterator.rb +13 -0
  29. data/lib/grape/validations/validator_factory.rb +6 -11
  30. data/lib/grape/validations/validators/all_or_none.rb +6 -13
  31. data/lib/grape/validations/validators/at_least_one_of.rb +5 -13
  32. data/lib/grape/validations/validators/base.rb +11 -10
  33. data/lib/grape/validations/validators/coerce.rb +4 -0
  34. data/lib/grape/validations/validators/default.rb +1 -1
  35. data/lib/grape/validations/validators/exactly_one_of.rb +6 -23
  36. data/lib/grape/validations/validators/multiple_params_base.rb +14 -10
  37. data/lib/grape/validations/validators/mutual_exclusion.rb +6 -18
  38. data/lib/grape/version.rb +1 -1
  39. data/spec/grape/api/defines_boolean_in_params_spec.rb +37 -0
  40. data/spec/grape/api_remount_spec.rb +158 -0
  41. data/spec/grape/api_spec.rb +72 -0
  42. data/spec/grape/endpoint_spec.rb +1 -1
  43. data/spec/grape/exceptions/base_spec.rb +4 -0
  44. data/spec/grape/exceptions/validation_errors_spec.rb +6 -4
  45. data/spec/grape/integration/rack_spec.rb +22 -6
  46. data/spec/grape/middleware/base_spec.rb +8 -0
  47. data/spec/grape/middleware/formatter_spec.rb +11 -1
  48. data/spec/grape/validations/multiple_attributes_iterator_spec.rb +29 -0
  49. data/spec/grape/validations/params_scope_spec.rb +13 -0
  50. data/spec/grape/validations/single_attribute_iterator_spec.rb +33 -0
  51. data/spec/grape/validations/validators/all_or_none_spec.rb +138 -30
  52. data/spec/grape/validations/validators/at_least_one_of_spec.rb +173 -29
  53. data/spec/grape/validations/validators/coerce_spec.rb +6 -2
  54. data/spec/grape/validations/validators/exactly_one_of_spec.rb +202 -38
  55. data/spec/grape/validations/validators/mutual_exclusion_spec.rb +184 -27
  56. data/spec/grape/validations_spec.rb +32 -20
  57. metadata +103 -115
  58. data/Appraisals +0 -28
  59. data/Dangerfile +0 -2
  60. data/Gemfile +0 -33
  61. data/Gemfile.lock +0 -231
  62. data/Guardfile +0 -10
  63. data/RELEASING.md +0 -111
  64. data/Rakefile +0 -25
  65. data/benchmark/simple.rb +0 -27
  66. data/benchmark/simple_with_type_coercer.rb +0 -22
  67. data/gemfiles/multi_json.gemfile +0 -35
  68. data/gemfiles/multi_xml.gemfile +0 -35
  69. data/gemfiles/rack_1.5.2.gemfile.lock +0 -232
  70. data/gemfiles/rack_edge.gemfile +0 -35
  71. data/gemfiles/rails_3.gemfile +0 -36
  72. data/gemfiles/rails_3.gemfile.lock +0 -288
  73. data/gemfiles/rails_4.gemfile +0 -35
  74. data/gemfiles/rails_4.gemfile.lock +0 -280
  75. data/gemfiles/rails_5.gemfile +0 -35
  76. data/gemfiles/rails_5.gemfile.lock +0 -312
  77. data/gemfiles/rails_edge.gemfile +0 -35
  78. data/pkg/grape-1.2.0.gem +0 -0
  79. data/pkg/grape-1.2.1.gem +0 -0
  80. data/pkg/grape-1.2.3.gem +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5943237e37e943a5a4e1d42bc6345f3af0e56509864050c7c12ba20b55d1bfb7
4
- data.tar.gz: 3221d07199e081a570a99fcfe42706d9a4934e8e34054071992f3a6f84a75844
3
+ metadata.gz: 8934b2070d7c44a7100315712c05ee9e76eff602290b30f475f6e2e324c5392c
4
+ data.tar.gz: 0d618a852be97bf103c7f783702342b030440834fedd725b4e6a90e03a8b0556
5
5
  SHA512:
6
- metadata.gz: 907e9a73f79bcd972ffc723215e824586875f6d10f6118ec591834a079def3aba630570c1ec3798e6e98b624b2c00e9523c4ad52821ea536873c837964cb2627
7
- data.tar.gz: 81af4b1f525ccb23ea9c7c6975099ff37283ffafac37cbd7a43c8cc93e06b344555464554859569b7ad573960e4dca11b428f7d5b96346eba2c7361c6beb526f
6
+ metadata.gz: f11c651eb7dea86dd45065c04cdebcbb2635cf8136536850b245d4ad94eac921a4218f191cc5f523968cdc4708ee7ede49fce17de21b97b96edcd82426c06795
7
+ data.tar.gz: 8266b0bf359c1ed96b7aacd9bbecacfe6ef5f406b94d54a1a9c6dfdbf18d95967f8c853f13dfab642631e261f81893bcc5323e83c0d27a04226bdc03d7b19381
@@ -1,18 +1,32 @@
1
- ### 1.2.5 (Next)
1
+ ### 1.2.5 (2019/12/01)
2
2
 
3
3
  #### Features
4
4
 
5
- * Your contribution here.
5
+ * [#1931](https://github.com/ruby-grape/grape/pull/1931): Introduces LazyBlock to generate expressions that will executed at mount time - [@myxoh](https://github.com/myxoh).
6
+ * [#1918](https://github.com/ruby-grape/grape/pull/1918): Helper methods to access controller context from middleware - [@NikolayRys](https://github.com/NikolayRys).
7
+ * [#1915](https://github.com/ruby-grape/grape/pull/1915): Micro optimizations in allocating hashes and arrays - [@dnesteryuk](https://github.com/dnesteryuk).
8
+ * [#1904](https://github.com/ruby-grape/grape/pull/1904): Allows Grape to load files on startup rather than on the first call - [@myxoh](https://github.com/myxoh).
9
+ * [#1907](https://github.com/ruby-grape/grape/pull/1907): Adds outside configuration to Grape with `configure` - [@unleashy](https://github.com/unleashy).
10
+ * [#1914](https://github.com/ruby-grape/grape/pull/1914): Run specs in random order - [@splattael](https://github.com/splattael).
6
11
 
7
12
  #### Fixes
8
13
 
9
- * Your contribution here.
14
+ * [#1917](https://github.com/ruby-grape/grape/pull/1917): Update access to rack constant - [@NikolayRys](https://github.com/NikolayRys).
15
+ * [#1916](https://github.com/ruby-grape/grape/pull/1916): Drop old appraisals - [@NikolayRys](https://github.com/NikolayRys).
16
+ * [#1911](https://github.com/ruby-grape/grape/pull/1911): Make sure `Grape::Valiations::AtLeastOneOfValidator` properly treats nested params in errors - [@dnesteryuk](https://github.com/dnesteryuk).
17
+ * [#1893](https://github.com/ruby-grape/grape/pull/1893): Allows `Grape::API` to behave like a Rack::app in some instances where it was misbehaving - [@myxoh](https://github.com/myxoh).
18
+ * [#1898](https://github.com/ruby-grape/grape/pull/1898): Refactor `ValidatorFactory` to improve memory allocation - [@Bhacaz](https://github.com/Bhacaz).
19
+ * [#1900](https://github.com/ruby-grape/grape/pull/1900): Define boolean for `Grape::Api::Instance` - [@Bhacaz](https://github.com/Bhacaz).
20
+ * [#1903](https://github.com/ruby-grape/grape/pull/1903): Allow nested params renaming (Hash/Array) - [@bikolya](https://github.com/bikolya).
21
+ * [#1913](https://github.com/ruby-grape/grape/pull/1913): Fix multiple params validators to return correct messages for nested params - [@bikolya](https://github.com/bikolya).
22
+ * [#1926](https://github.com/ruby-grape/grape/pull/1926): Fixes configuration within given or mounted blocks - [@myxoh](https://github.com/myxoh).
23
+ * [#1937](https://github.com/ruby-grape/grape/pull/1937): Fix bloat in released gem - [@dblock](https://github.com/dblock).
10
24
 
11
25
  ### 1.2.4 (2019/06/13)
12
26
 
13
27
  #### Features
14
28
 
15
- * [#1888](https://github.com/ruby-grape/grape/pull/1888): Makes the `configuration` hash widly available - [@myxoh](https://github.com/myxoh).
29
+ * [#1888](https://github.com/ruby-grape/grape/pull/1888): Makes the `configuration` hash widely available - [@myxoh](https://github.com/myxoh).
16
30
  * [#1864](https://github.com/ruby-grape/grape/pull/1864): Adds `finally` on the API - [@myxoh](https://github.com/myxoh).
17
31
  * [#1869](https://github.com/ruby-grape/grape/pull/1869): Fix issue with empty headers after `error!` method call - [@anaumov](https://github.com/anaumov).
18
32
 
data/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  - [Installation](#installation)
16
16
  - [Basic Usage](#basic-usage)
17
17
  - [Mounting](#mounting)
18
+ - [All](#all)
18
19
  - [Rack](#rack)
19
20
  - [ActiveRecord without Rails](#activerecord-without-rails)
20
21
  - [Alongside Sinatra (or other frameworks)](#alongside-sinatra-or-other-frameworks)
@@ -153,9 +154,8 @@ content negotiation, versioning and much more.
153
154
 
154
155
  ## Stable Release
155
156
 
156
- You're reading the documentation for the next release of Grape, which should be **1.2.5**.
157
+ You're reading the documentation for the stable release of Grape, **1.2.5**.
157
158
  Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
158
- The current stable release is [1.2.4](https://github.com/ruby-grape/grape/blob/v1.2.4/README.md).
159
159
 
160
160
  ## Project Resources
161
161
 
@@ -213,7 +213,7 @@ module Twitter
213
213
 
214
214
  desc 'Return a status.'
215
215
  params do
216
- requires :id, type: Integer, desc: 'Status id.'
216
+ requires :id, type: Integer, desc: 'Status ID.'
217
217
  end
218
218
  route_param :id do
219
219
  get do
@@ -261,6 +261,17 @@ end
261
261
 
262
262
  ## Mounting
263
263
 
264
+ ### All
265
+
266
+
267
+ By default Grape will compile the routes on the first route, it is possible to pre-load routes using the `compile!` method.
268
+
269
+ ```ruby
270
+ Twitter::API.compile!
271
+ ```
272
+
273
+ This can be added to your `config.ru` (if using rackup), `application.rb` (if using rails), or any file that loads your server.
274
+
264
275
  ### Rack
265
276
 
266
277
  The above sample creates a Rack application that can be run from a rackup `config.ru` file
@@ -270,6 +281,13 @@ with `rackup`:
270
281
  run Twitter::API
271
282
  ```
272
283
 
284
+ (With pre-loading you can use)
285
+
286
+ ```ruby
287
+ Twitter::API.compile!
288
+ run Twitter::API
289
+ ```
290
+
273
291
  And would respond to the following routes:
274
292
 
275
293
  GET /api/statuses/public_timeline
@@ -437,6 +455,15 @@ class Comment::API < Grape::API
437
455
  end
438
456
  ```
439
457
 
458
+ Note that if you're passing a hash as the first parameter to `mount`, you will need to explicitly put `()` around parameters:
459
+ ```ruby
460
+ # good
461
+ mount({ ::Some::Api => '/some/api' }, with: { condition: true })
462
+
463
+ # bad
464
+ mount ::Some::Api => '/some/api', with: { condition: true }
465
+ ```
466
+
440
467
  You can access `configuration` on the class (to use as dynamic attributes), inside blocks (like namespace)
441
468
 
442
469
  If you want logic happening given on an `configuration`, you can use the helper `given`.
@@ -466,6 +493,42 @@ class ConditionalEndpoint::API < Grape::API
466
493
  end
467
494
  ```
468
495
 
496
+ More complex results can be achieved by using `mounted` as an expression within which the `configuration` is already evaluated as a Hash.
497
+
498
+ ```ruby
499
+ class ExpressionEndpointAPI < Grape::API
500
+ get(mounted { configuration[:route_name] || 'default_name' }) do
501
+ # some logic
502
+ end
503
+ end
504
+ ```
505
+
506
+ ```ruby
507
+ class BasicAPI < Grape::API
508
+ desc 'Statuses index' do
509
+ params: mounted { configuration[:entity] || API::Entities::Status }.documentation
510
+ end
511
+ params do
512
+ requires :all, using: mounted { configuration[:entity] || API::Entities::Status }.documentation
513
+ end
514
+ get '/statuses' do
515
+ statuses = Status.all
516
+ type = current_user.admin? ? :full : :default
517
+ present statuses, with: mounted { configuration[:entity] || API::Entities::Status }, type: type
518
+ end
519
+ end
520
+
521
+ class V1 < Grape::API
522
+ version 'v1'
523
+ mount BasicAPI, with: { entity: mounted { configuration[:entity] || API::Enitities::Status } }
524
+ end
525
+
526
+ class V2 < Grape::API
527
+ version 'v2'
528
+ mount BasicAPI, with: { entity: mounted { configuration[:entity] || API::Enitities::V2::Status } }
529
+ end
530
+ ```
531
+
469
532
  ## Versioning
470
533
 
471
534
  There are four strategies in which clients can reach your API's endpoints: `:path`,
@@ -612,6 +675,17 @@ Grape.configure do |config|
612
675
  end
613
676
  ```
614
677
 
678
+ You can also configure a single API:
679
+
680
+ ```ruby
681
+ API.configure do |config|
682
+ config[key] = value
683
+ end
684
+ ```
685
+
686
+ This will be available inside the API with `configuration`, as if it were
687
+ [mount configuration](#mount-configuration).
688
+
615
689
  ## Parameters
616
690
 
617
691
  Request parameters are available through the `params` hash object. This includes `GET`, `POST`
@@ -1886,6 +1960,56 @@ error! 'Unauthorized', 401, 'X-Error-Detail' => 'Invalid token.'
1886
1960
 
1887
1961
  ## Routes
1888
1962
 
1963
+ To define routes you can use the `route` method or the shorthands for the HTTP verbs. To define a route that accepts any route set to `:any`.
1964
+ Parts of the path that are denoted with a colon will be interpreted as route parameters.
1965
+
1966
+ ```ruby
1967
+ route :get, 'status' do
1968
+ end
1969
+
1970
+ # is the same as
1971
+
1972
+ get 'status' do
1973
+ end
1974
+
1975
+ # is the same as
1976
+
1977
+ get :status do
1978
+ end
1979
+
1980
+ # is NOT the same as
1981
+
1982
+ get ':status' do # this makes param[:status] available
1983
+ end
1984
+
1985
+ # This will make both param[:status_id] and param[:id] available
1986
+
1987
+ get 'statuses/:status_id/reviews/:id' do
1988
+ end
1989
+ ```
1990
+
1991
+ To declare a namespace that prefixes all routes within, use the `namespace` method. `group`, `resource`, `resources` and `segment` are aliases to this method. Any endpoints within will share their parent context as well as any configuration done in the namespace context.
1992
+
1993
+ The `route_param` method is a convenient method for defining a parameter route segment. If you define a type, it will add a validation for this parameter.
1994
+
1995
+ ```ruby
1996
+ route_param :id, type: Integer do
1997
+ get 'status' do
1998
+ end
1999
+ end
2000
+
2001
+ # is the same as
2002
+
2003
+ namespace ':id' do
2004
+ params do
2005
+ requires :id, type: Integer
2006
+ end
2007
+
2008
+ get 'status' do
2009
+ end
2010
+ end
2011
+ ```
2012
+
1889
2013
  Optionally, you can define requirements for your named route parameters using regular
1890
2014
  expressions on namespace or endpoint. The route will match only if all requirements are met.
1891
2015
 
@@ -2467,6 +2591,17 @@ class Twitter::API < Grape::API
2467
2591
  end
2468
2592
  ```
2469
2593
 
2594
+ Inside the `rescue_from` block, the environment of the original controller method(`.self` receiver) is accessible through the `#context` method.
2595
+
2596
+ ```ruby
2597
+ class Twitter::API < Grape::API
2598
+ rescue_from :all do |e|
2599
+ user_id = context.params[:user_id]
2600
+ error!("error for #{user_id}")
2601
+ end
2602
+ end
2603
+ ```
2604
+
2470
2605
  #### Rescuing exceptions inside namespaces
2471
2606
 
2472
2607
  You could put `rescue_from` clauses inside a namespace and they will take precedence over ones
@@ -2489,7 +2624,7 @@ class Twitter::API < Grape::API
2489
2624
  end
2490
2625
  ```
2491
2626
 
2492
- Here `'inner'` will be result of handling occured `ArgumentError`.
2627
+ Here `'inner'` will be result of handling occurred `ArgumentError`.
2493
2628
 
2494
2629
  #### Unrescuable Exceptions
2495
2630
 
@@ -3091,6 +3226,8 @@ end
3091
3226
 
3092
3227
  Use [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper), [warden-oauth2](https://github.com/opperator/warden-oauth2) or [rack-oauth2](https://github.com/nov/rack-oauth2) for OAuth2 support.
3093
3228
 
3229
+ You can access the controller params, headers, and helpers through the context with the `#context` method inside any auth middleware inherited from `Grape::Middlware::Auth::Base`.
3230
+
3094
3231
  ## Describing and Inspecting an API
3095
3232
 
3096
3233
  Grape routes can be reflected at runtime. This can notably be useful for generating documentation.
@@ -3403,6 +3540,8 @@ class API < Grape::API
3403
3540
  end
3404
3541
  ```
3405
3542
 
3543
+ You can access the controller params, headers, and helpers through the context with the `#context` method inside any middleware inherited from `Grape::Middlware::Base`.
3544
+
3406
3545
  ### Rails Middleware
3407
3546
 
3408
3547
  Note that when you're using Grape mounted on Rails you don't have to use Rails middleware because it's already included into your middleware stack.
@@ -3711,6 +3850,7 @@ Grape integrates with following third-party tools:
3711
3850
  * **Librato Metrics** - [grape-librato](https://github.com/seanmoon/grape-librato) gem
3712
3851
  * **[Skylight](https://www.skylight.io/)** - [skylight](https://github.com/skylightio/skylight-ruby) gem, [documentation](https://docs.skylight.io/grape/)
3713
3852
  * **[AppSignal](https://www.appsignal.com)** - [appsignal-ruby](https://github.com/appsignal/appsignal-ruby) gem, [documentation](http://docs.appsignal.com/getting-started/supported-frameworks.html#grape)
3853
+ * **[ElasticAPM](https://www.elastic.co/products/apm) - [elastic-apm](https://github.com/elastic/apm-agent-ruby) gem, [documentation](https://www.elastic.co/guide/en/apm/agent/ruby/3.x/getting-started-rack.html#getting-started-grape)
3714
3854
 
3715
3855
  ## Contributing to Grape
3716
3856
 
@@ -19,7 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'rack-accept'
20
20
  s.add_runtime_dependency 'virtus', '>= 1.0.0'
21
21
 
22
- s.files = Dir['**/*'].keep_if { |file| File.file?(file) }
22
+ s.files = %w[CHANGELOG.md CONTRIBUTING.md README.md grape.png UPGRADING.md LICENSE]
23
+ s.files += %w[grape.gemspec]
24
+ s.files += Dir['lib/**/*']
23
25
  s.test_files = Dir['spec/**/*']
24
26
  s.require_paths = ['lib']
25
27
  end
@@ -54,106 +54,125 @@ module Grape
54
54
 
55
55
  module Exceptions
56
56
  extend ::ActiveSupport::Autoload
57
- autoload :Base
58
- autoload :Validation
59
- autoload :ValidationArrayErrors
60
- autoload :ValidationErrors
61
- autoload :MissingVendorOption
62
- autoload :MissingMimeType
63
- autoload :MissingOption
64
- autoload :InvalidFormatter
65
- autoload :InvalidVersionerOption
66
- autoload :UnknownValidator
67
- autoload :UnknownOptions
68
- autoload :UnknownParameter
69
- autoload :InvalidWithOptionForRepresent
70
- autoload :IncompatibleOptionValues
71
- autoload :MissingGroupTypeError, 'grape/exceptions/missing_group_type'
72
- autoload :UnsupportedGroupTypeError, 'grape/exceptions/unsupported_group_type'
73
- autoload :InvalidMessageBody
74
- autoload :InvalidAcceptHeader
75
- autoload :InvalidVersionHeader
76
- autoload :MethodNotAllowed
77
- autoload :InvalidResponse
57
+ eager_autoload do
58
+ autoload :Base
59
+ autoload :Validation
60
+ autoload :ValidationArrayErrors
61
+ autoload :ValidationErrors
62
+ autoload :MissingVendorOption
63
+ autoload :MissingMimeType
64
+ autoload :MissingOption
65
+ autoload :InvalidFormatter
66
+ autoload :InvalidVersionerOption
67
+ autoload :UnknownValidator
68
+ autoload :UnknownOptions
69
+ autoload :UnknownParameter
70
+ autoload :InvalidWithOptionForRepresent
71
+ autoload :IncompatibleOptionValues
72
+ autoload :MissingGroupTypeError, 'grape/exceptions/missing_group_type'
73
+ autoload :UnsupportedGroupTypeError, 'grape/exceptions/unsupported_group_type'
74
+ autoload :InvalidMessageBody
75
+ autoload :InvalidAcceptHeader
76
+ autoload :InvalidVersionHeader
77
+ autoload :MethodNotAllowed
78
+ autoload :InvalidResponse
79
+ end
78
80
  end
79
81
 
80
82
  module Extensions
81
83
  extend ::ActiveSupport::Autoload
82
-
83
- autoload :DeepMergeableHash
84
- autoload :DeepSymbolizeHash
85
- autoload :DeepHashWithIndifferentAccess
86
- autoload :Hash
87
-
84
+ eager_autoload do
85
+ autoload :DeepMergeableHash
86
+ autoload :DeepSymbolizeHash
87
+ autoload :DeepHashWithIndifferentAccess
88
+ autoload :Hash
89
+ end
88
90
  module ActiveSupport
89
91
  extend ::ActiveSupport::Autoload
90
-
91
- autoload :HashWithIndifferentAccess
92
+ eager_autoload do
93
+ autoload :HashWithIndifferentAccess
94
+ end
92
95
  end
93
96
 
94
97
  module Hashie
95
98
  extend ::ActiveSupport::Autoload
96
-
97
- autoload :Mash
99
+ eager_autoload do
100
+ autoload :Mash
101
+ end
98
102
  end
99
103
  end
100
104
 
101
105
  module Middleware
102
106
  extend ::ActiveSupport::Autoload
103
- autoload :Base
104
- autoload :Versioner
105
- autoload :Formatter
106
- autoload :Error
107
- autoload :Globals
108
- autoload :Stack
107
+ eager_autoload do
108
+ autoload :Base
109
+ autoload :Versioner
110
+ autoload :Formatter
111
+ autoload :Error
112
+ autoload :Globals
113
+ autoload :Stack
114
+ autoload :Helpers
115
+ end
109
116
 
110
117
  module Auth
111
118
  extend ::ActiveSupport::Autoload
112
- autoload :Base
113
- autoload :DSL
114
- autoload :StrategyInfo
115
- autoload :Strategies
119
+ eager_autoload do
120
+ autoload :Base
121
+ autoload :DSL
122
+ autoload :StrategyInfo
123
+ autoload :Strategies
124
+ end
116
125
  end
117
126
 
118
127
  module Versioner
119
128
  extend ::ActiveSupport::Autoload
120
- autoload :Path
121
- autoload :Header
122
- autoload :Param
123
- autoload :AcceptVersionHeader
129
+ eager_autoload do
130
+ autoload :Path
131
+ autoload :Header
132
+ autoload :Param
133
+ autoload :AcceptVersionHeader
134
+ end
124
135
  end
125
136
  end
126
137
 
127
138
  module Util
128
139
  extend ::ActiveSupport::Autoload
129
- autoload :InheritableValues
130
- autoload :StackableValues
131
- autoload :ReverseStackableValues
132
- autoload :InheritableSetting
133
- autoload :StrictHashConfiguration
134
- autoload :Registrable
140
+ eager_autoload do
141
+ autoload :InheritableValues
142
+ autoload :StackableValues
143
+ autoload :ReverseStackableValues
144
+ autoload :InheritableSetting
145
+ autoload :StrictHashConfiguration
146
+ autoload :Registrable
147
+ end
135
148
  end
136
149
 
137
150
  module ErrorFormatter
138
151
  extend ::ActiveSupport::Autoload
139
- autoload :Base
140
- autoload :Json
141
- autoload :Txt
142
- autoload :Xml
152
+ eager_autoload do
153
+ autoload :Base
154
+ autoload :Json
155
+ autoload :Txt
156
+ autoload :Xml
157
+ end
143
158
  end
144
159
 
145
160
  module Formatter
146
161
  extend ::ActiveSupport::Autoload
147
- autoload :Json
148
- autoload :SerializableHash
149
- autoload :Txt
150
- autoload :Xml
162
+ eager_autoload do
163
+ autoload :Json
164
+ autoload :SerializableHash
165
+ autoload :Txt
166
+ autoload :Xml
167
+ end
151
168
  end
152
169
 
153
170
  module Parser
154
171
  extend ::ActiveSupport::Autoload
155
- autoload :Json
156
- autoload :Xml
172
+ eager_autoload do
173
+ autoload :Json
174
+ autoload :Xml
175
+ end
157
176
  end
158
177
 
159
178
  module DSL
@@ -177,29 +196,38 @@ module Grape
177
196
 
178
197
  class API
179
198
  extend ::ActiveSupport::Autoload
180
- autoload :Helpers
199
+ eager_autoload do
200
+ autoload :Helpers
201
+ end
181
202
  end
182
203
 
183
204
  module Presenters
184
205
  extend ::ActiveSupport::Autoload
185
- autoload :Presenter
206
+ eager_autoload do
207
+ autoload :Presenter
208
+ end
186
209
  end
187
210
 
188
211
  module ServeFile
189
212
  extend ::ActiveSupport::Autoload
190
- autoload :FileResponse
191
- autoload :FileBody
192
- autoload :SendfileResponse
213
+ eager_autoload do
214
+ autoload :FileResponse
215
+ autoload :FileBody
216
+ autoload :SendfileResponse
217
+ end
193
218
  end
194
219
  end
195
220
 
196
221
  require 'grape/config'
197
222
  require 'grape/util/content_types'
198
223
  require 'grape/util/lazy_value'
224
+ require 'grape/util/lazy_block'
199
225
  require 'grape/util/endpoint_configuration'
200
226
 
201
227
  require 'grape/validations/validators/base'
202
228
  require 'grape/validations/attributes_iterator'
229
+ require 'grape/validations/single_attribute_iterator'
230
+ require 'grape/validations/multiple_attributes_iterator'
203
231
  require 'grape/validations/validators/allow_blank'
204
232
  require 'grape/validations/validators/as'
205
233
  require 'grape/validations/validators/at_least_one_of'