Sha256: dd2649d9d465d155ba51bf23549caff1e72441ded5ac87a61efa0ef220454ab9

Contents?: true

Size: 1.21 KB

Versions: 8

Compression:

Stored size: 1.21 KB

Contents

module Brakeman::RouteHelper
  #Manage Controller prefixes
  #@prefix is an Array, but this method returns a string
  #suitable for prefixing onto a controller name.
  def prefix
    if @prefix.length > 0
      @prefix.join("::") << "::"
    else
      ''
    end
  end

  #Sets the controller name to a proper class name.
  #For example
  # self.current_controller = :session
  # @controller == :SessionController #true
  #
  #Also prepends the prefix if there is one set.
  def current_controller= name
    @current_controller = (prefix + camelize(name) + "Controller").to_sym
    @tracker.routes[@current_controller] ||= Set.new
  end

  #Add default routes
  def add_resources_routes
    existing_routes = @tracker.routes[@current_controller]

    unless existing_routes.is_a? Array and existing_routes.first == :allow_all_actions
      existing_routes.merge [:index, :new, :create, :show, :edit, :update, :destroy]
    end
  end

  #Add default routes minus :index
  def add_resource_routes
    existing_routes = @tracker.routes[@current_controller]

    unless existing_routes.is_a? Array and existing_routes.first == :allow_all_actions
      existing_routes.merge [:new, :create, :show, :edit, :update, :destroy]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
brakeman-1.6.2 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.6.1 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.6.0 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.6.0.pre1 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.5.3 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.5.2 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.5.1 lib/brakeman/processors/lib/route_helper.rb
brakeman-1.5.0 lib/brakeman/processors/lib/route_helper.rb