Module: JumpBack::HelpersArguments

Defined in:
lib/jump_back/link_back.rb

Class Method Summary collapse

Class Method Details

.first_arg_is_path?(name, path, root_path) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/jump_back/link_back.rb', line 27

def self.first_arg_is_path?(name, path, root_path)
  Urls.is_url?(name) && (path == root_path || path.is_a?(Hash))
end

.parse(name, path, options, root_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jump_back/link_back.rb', line 13

def self.parse(name, path, options, root_path)
  if first_arg_is_path?(name, path, root_path)
    options = path if path.is_a? Hash
    path = name
    name = 'back'
  end
  if name.is_a? Hash
    options = name
    name = 'back'
  end
  options = OptionsParser.new(default: root_path, path: path, options: options)
  { name: name, path: options.path, jump_back_options: options.jump_back_options, redirect_options: options.redirect_options }
end