Class: JumpBack::OptionsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/jump_back/options_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ OptionsParser

Returns a new instance of OptionsParser.



7
8
9
10
11
# File 'lib/jump_back/options_parser.rb', line 7

def initialize(options)
  @path = parse(options)[:path]
  @redirect_options = parse(options)[:redirect_options]
  @jump_back_options = parse(options)[:jump_back_options]
end

Instance Attribute Details

#jump_back_optionsObject (readonly)

Returns the value of attribute jump_back_options.



5
6
7
# File 'lib/jump_back/options_parser.rb', line 5

def jump_back_options
  @jump_back_options
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/jump_back/options_parser.rb', line 5

def path
  @path
end

#redirect_optionsObject (readonly)

Returns the value of attribute redirect_options.



5
6
7
# File 'lib/jump_back/options_parser.rb', line 5

def redirect_options
  @redirect_options
end

Instance Method Details

#parse(options) ⇒ Object



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

def parse(options)
  return @options if @options
  
  if options[:path].is_a? Hash
    options[:options] = options[:path]
    options[:path] = options[:default]
  end
  
  options[:jump_back_options] = { offsite: options[:options].delete(:offsite) }
  options[:redirect_options] = options.delete(:options)
  @options = options
end