Class: GrapeApiary::Config
- Inherits:
-
Object
- Object
- GrapeApiary::Config
- Defined in:
- lib/grape-apiary/config.rb
Constant Summary collapse
- SETTINGS =
%i( host name description request_headers response_headers example_id_type resource_exclusion include_root ).freeze
Class Method Summary collapse
- .example_id_type ⇒ Object
- .example_id_type=(value) ⇒ Object
- .generate_id ⇒ Object
- .include_root ⇒ Object
- .request_headers ⇒ Object
- .resource_exclusion ⇒ Object
- .response_headers ⇒ Object
- .supported_id_types ⇒ Object
Class Method Details
.example_id_type ⇒ Object
47 48 49 |
# File 'lib/grape-apiary/config.rb', line 47 def example_id_type @example_id_type ||= :integer end |
.example_id_type=(value) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/grape-apiary/config.rb', line 37 def example_id_type=(value) raise UnsupportedIDType unless supported_id_types.include?(value) if value.to_sym == :bson && !Object.const_defined?('BSON') raise BSONNotDefinied end @example_id_type = value end |
.generate_id ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/grape-apiary/config.rb', line 51 def generate_id case example_id_type when :integer SecureRandom.random_number(1000) when :uuid SecureRandom.uuid when :bson BSON::ObjectId.new.to_s end end |
.include_root ⇒ Object
29 30 31 |
# File 'lib/grape-apiary/config.rb', line 29 def include_root @include_root ||= false end |
.request_headers ⇒ Object
17 18 19 |
# File 'lib/grape-apiary/config.rb', line 17 def request_headers @request_headers ||= [] end |
.resource_exclusion ⇒ Object
25 26 27 |
# File 'lib/grape-apiary/config.rb', line 25 def resource_exclusion @resource_exclusion ||= [] end |
.response_headers ⇒ Object
21 22 23 |
# File 'lib/grape-apiary/config.rb', line 21 def response_headers @response_headers ||= [] end |
.supported_id_types ⇒ Object
33 34 35 |
# File 'lib/grape-apiary/config.rb', line 33 def supported_id_types %i(integer uuid bson) end |