Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/wizardry/routes.rb

Instance Method Summary collapse

Instance Method Details

#has_wizardryObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wizardry/routes.rb', line 2

def has_wizardry
  unless resource_scope?
    raise ArgumentError, "can't use has_wizardry outside resource(s) scope"
  end

  options = @scope[:scope_level_resource].options

  if options.has_key?(:only)
    only = Array.wrap(options.delete(:only))
    only.map!(&:to_sym).delete(:edit)
    options.merge!(only: only) if only.present?
  end

  except = Array.wrap(options.delete(:except))
  except.map!(&:to_sym) << :edit
  options.merge!(except: except.uniq)

  res = @scope[:scope_level_resource].instance_variable_get(:@name)

  get 'edit/:step' => :edit, step: res.to_s.classify.constantize.steps_regexp, as: :edit, on: :member
end