Class: Grape::DSL::VersionOptions

Inherits:
Data
  • Object
show all
Defined in:
lib/grape/dsl/version_options.rb

Overview

Immutable value object holding the resolved options from Grape::DSL::Routing#version. Stored on the inheritable settings as namespace_inheritable[:version_options] and read by internal call sites (‘Path`, `Endpoint`, `API::Instance#cascade?`, `Middleware::Versioner::Base`) via accessors.

Defaults are duplicated on #initialize here and on #version‘s signature on purpose: keeping them on both sides means each entry point is self-documenting without needing to import a shared constant — the DSL signature shows what a user sees in the IDE, and the Data object has working defaults when constructed directly (middleware `DEFAULT_OPTIONS`, spec fixtures, etc.). The two must stay in lockstep.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(using: :path, cascade: true, parameter: 'apiver', strict: false, vendor: nil) ⇒ VersionOptions

Returns a new instance of VersionOptions.



18
19
20
# File 'lib/grape/dsl/version_options.rb', line 18

def initialize(using: :path, cascade: true, parameter: 'apiver', strict: false, vendor: nil)
  super
end

Instance Attribute Details

#cascadeObject (readonly)

Returns the value of attribute cascade

Returns:

  • (Object)

    the current value of cascade



17
18
19
# File 'lib/grape/dsl/version_options.rb', line 17

def cascade
  @cascade
end

#parameterObject (readonly)

Returns the value of attribute parameter

Returns:

  • (Object)

    the current value of parameter



17
18
19
# File 'lib/grape/dsl/version_options.rb', line 17

def parameter
  @parameter
end

#strictObject (readonly)

Returns the value of attribute strict

Returns:

  • (Object)

    the current value of strict



17
18
19
# File 'lib/grape/dsl/version_options.rb', line 17

def strict
  @strict
end

#usingObject (readonly)

Returns the value of attribute using

Returns:

  • (Object)

    the current value of using



17
18
19
# File 'lib/grape/dsl/version_options.rb', line 17

def using
  @using
end

#vendorObject (readonly)

Returns the value of attribute vendor

Returns:

  • (Object)

    the current value of vendor



17
18
19
# File 'lib/grape/dsl/version_options.rb', line 17

def vendor
  @vendor
end