Class: Grape::Endpoint::Options
- Inherits:
-
Data
- Object
- Data
- Grape::Endpoint::Options
- Defined in:
- lib/grape/endpoint/options.rb
Overview
Immutable value object holding the keyword inputs passed to
Grape::Endpoint.new. Internal to Grape::Endpoint, which builds it
from the **options Hash in #initialize so the public options reader
stays a plain Hash for downstream gems (e.g. grape-swagger).
Instance Attribute Summary collapse
-
#anchor ⇒ Object
readonly
Returns the value of attribute anchor.
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#http_methods ⇒ Object
readonly
Returns the value of attribute http_methods.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#requirements ⇒ Object
readonly
Returns the value of attribute requirements.
-
#route_options ⇒ Object
readonly
Returns the value of attribute route_options.
Instance Method Summary collapse
-
#initialize(path:, http_methods:, api:, route_options: {}, app: nil, params: {}, requirements: nil, anchor: true) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(path:, http_methods:, api:, route_options: {}, app: nil, params: {}, requirements: nil, anchor: true) ⇒ Options
Returns a new instance of Options.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/grape/endpoint/options.rb', line 10 def initialize(path:, http_methods:, api:, route_options: {}, app: nil, params: {}, requirements: nil, anchor: true) # +Array()+ hands back the very Array it was given, so defaulting an # empty one by appending would append to the caller's Array — and raise # FrozenError on a frozen one. Build a new Array instead of growing # theirs: nothing about constructing an endpoint should be visible in # the path the caller passed in. paths = Array(path) super( path: paths.presence || ['/'], http_methods: Array(http_methods), api:, route_options:, app:, params:, requirements:, anchor: ) end |
Instance Attribute Details
#anchor ⇒ Object (readonly)
Returns the value of attribute anchor
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def anchor @anchor end |
#api ⇒ Object (readonly)
Returns the value of attribute api
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def api @api end |
#app ⇒ Object (readonly)
Returns the value of attribute app
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def app @app end |
#http_methods ⇒ Object (readonly)
Returns the value of attribute http_methods
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def http_methods @http_methods end |
#params ⇒ Object (readonly)
Returns the value of attribute params
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def path @path end |
#requirements ⇒ Object (readonly)
Returns the value of attribute requirements
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def requirements @requirements end |
#route_options ⇒ Object (readonly)
Returns the value of attribute route_options
9 10 11 |
# File 'lib/grape/endpoint/options.rb', line 9 def @route_options end |