lib/pagelet_rails/concerns/routes.rb in pagelet_rails-0.1.1 vs lib/pagelet_rails/concerns/routes.rb in pagelet_rails-0.1.2
- old
+ new
@@ -27,55 +27,17 @@
@pagelet_routes << Proc.new do
resource controller_name, *args, opts, &block
end
end
- # Define inline single route for the following method.
- # It automatically adds :controller and :action names to the route
- #
- # class PageletRails::Examples::ExamplesController
- # pageletlet_route :get, ''
- # def bingo
- # end
- # end
- #
- # will generate routes
- # Helper: pagelets_examples_path
- # HTTP Verb: GET
- # Path: /pagelets/examples(.:format)
- # Controller#Action: pagelets/examples/examples#bingo
- #
- def pagelet_route *args
- @pagelet_route << args
- end
-
- def method_added method_name
- return unless @pagelet_route
- @pagelet_route.each do |args|
- options = args.extract_options!
- options[:controller] ||= self.controller_name
- options[:action] ||= method_name
-
- @pagelet_routes << Proc.new do
- scope path: options[:controller], as: options[:controller] do
- self.send *args, options
- end
- end
- end
-
- @pagelet_route = []
- super
- end
-
def load_pagelet_routes! context
@pagelet_routes.each do |proc|
- context.instance_eval &proc
+ context.instance_eval(&proc)
end
end
def inherited subklass
subklass.instance_variable_set(:@pagelet_routes, [])
- subklass.instance_variable_set(:@pagelet_route, [])
super
end
end
end