Class: Grape::Endpoint::Options

Inherits:
Data
  • Object
show all
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). :method is renamed to :http_methods on the value object to avoid shadowing Object#method via the generated Data accessor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, method:, route_options: {}, app: nil, format: nil, forward_match: nil, **rest) ⇒ Options

Returns a new instance of Options.



12
13
14
15
16
# File 'lib/grape/endpoint/options.rb', line 12

def initialize(path:, method:, route_options: {}, app: nil, format: nil, forward_match: nil, **rest)
  path = Array(path)
  path << '/' if path.empty?
  super(path:, http_methods: Array(method), route_options:, app:, format:, forward_match:, **rest)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app

Returns:

  • (Object)

    the current value of app



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def app
  @app
end

#forObject (readonly)

Returns the value of attribute for

Returns:

  • (Object)

    the current value of for



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def for
  @for
end

#formatObject (readonly)

Returns the value of attribute format

Returns:

  • (Object)

    the current value of format



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def format
  @format
end

#forward_matchObject (readonly)

Returns the value of attribute forward_match

Returns:

  • (Object)

    the current value of forward_match



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def forward_match
  @forward_match
end

#http_methodsObject (readonly)

Returns the value of attribute http_methods

Returns:

  • (Object)

    the current value of http_methods



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def http_methods
  @http_methods
end

#pathObject (readonly)

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def path
  @path
end

#route_optionsObject (readonly)

Returns the value of attribute route_options

Returns:

  • (Object)

    the current value of route_options



11
12
13
# File 'lib/grape/endpoint/options.rb', line 11

def route_options
  @route_options
end