module ActionDispatch::Routing
class RouteSet
def draw_with_lolita *args,&block
unless Lolita::Navigation::Tree[:"left_side_navigation"]
tree=Lolita::Navigation::Tree.new(:"left_side_navigation")
Lolita::Navigation::Tree.remember(tree)
end
draw_without_lolita *args,&block
end
alias_method_chain :draw, :lolita
end
class Mapper
# Every module, that is used with lolita and has routes, need to have
# resource method
, for example, lolita_rest, that should be added
# to ActionDispatch::Routing::Mapper class, as a *protected* method.
# Module can automaticliy add resource route or allow user to do it.
# It accepts some useful options
# * :module
# * :path
# * :as
# * :path_prefix
# * :controller
# * :class_name
# * :singular
# ====Example
# Lolita.add_module Lolita::Gallery,:route=>:gallery
# # in route.rb
# lolita_for :galleries
# # lolita_for try to call :lolita_gallery in Mapper class
def lolita_for *resources
#TODO refactor
return if migrating?
options = resources.extract_options!
# if as = options.delete(:as)
# ActiveSupport::Deprecation.warn ":as is deprecated, please use :path instead."
# options[:path] ||= as
# end
# if scope = options.delete(:scope)
# ActiveSupport::Deprecation.warn ":scope is deprecated, please use :singular instead."
# options[:singular] ||= scope
# end
options[:as] ||= @scope[:as] if @scope[:as].present?
options[:module] ||= @scope[:module] if @scope[:module].present?
options[:path_prefix] ||= @scope[:path] if @scope[:path].present?
resources.map!(&:to_sym)
all_resource_classes=[]
resources.each{|resource|
mapping=Lolita.add_mapping(resource,options)
Lolita.resources[mapping.name]=mapping
target_class=mapping.to
Lolita::Navigation::Tree[:"left_side_navigation"].append(mapping,:title=>mapping.name.to_s.humanize)
all_resource_classes<