Class: ApiSignature::SpecSupport::PathBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/api_signature/spec_support/path_builder.rb

Constant Summary collapse

PRIMARY_KEYS =
[:id, :token].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, action_name, params = {}) ⇒ PathBuilder

Returns a new instance of PathBuilder.



10
11
12
13
14
# File 'lib/api_signature/spec_support/path_builder.rb', line 10

def initialize(controller, action_name, params = {})
  @controller = controller
  @action_name = action_name
  @params = params
end

Instance Attribute Details

#action_nameObject (readonly)

Returns the value of attribute action_name.



6
7
8
# File 'lib/api_signature/spec_support/path_builder.rb', line 6

def action_name
  @action_name
end

#controllerObject (readonly)

Returns the value of attribute controller.



6
7
8
# File 'lib/api_signature/spec_support/path_builder.rb', line 6

def controller
  @controller
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/api_signature/spec_support/path_builder.rb', line 6

def params
  @params
end

Instance Method Details

#pathObject



16
17
18
19
20
21
22
23
24
# File 'lib/api_signature/spec_support/path_builder.rb', line 16

def path
  if params[:path].present?
    hash = params.delete(:path)
    url_options.merge!(hash)
    params.merge!(hash)
  end

  controller.url_for(url_options)
end