Sha256: 23ac4358ccd923f55b5f1decc4a857b3a96322b897803b8e43169428e86dc95a
Contents?: true
Size: 1.49 KB
Versions: 4
Compression:
Stored size: 1.49 KB
Contents
class Jets::Router class MethodCreator include Util def initialize(options, scope) @options, @scope = options, scope @controller, @action = get_controller_action(@options) end def define_url_helper! return unless @options[:method] == :get if %w[index new show edit].include?(@action) create_method(@action) else create_method("generic") end end # Examples: # # posts_path: path: 'posts' # admin_posts_path: prefix: 'admin', path: 'posts' # new_post_path # def create_method(action) # Code eventually does this: # # code = Jets::Router::MethodCreator::Edit.new # def_meth code.path_method # class_name = "Jets::Router::MethodCreator::#{action.camelize}" klass = class_name.constantize # Index, Show, Edit, New code = klass.new(@options, @scope, @controller) # puts "define_#{action}_methods:".color(:yellow) if code.path_method # puts code.path_method.color(:blue) if code.path_method # puts code.url_method.color(:blue) if code.url_method def_meth(code.path_method) if code.path_method def_meth(code.url_method) if code.url_method end def create_root_helper code = Jets::Router::MethodCreator::Root.new(@options, @scope, @controller) def_meth(code.path_method) def_meth(code.url_method) end def def_meth(str) Jets::Router::Helpers::NamedRoutesHelper.class_eval(str) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
jets-2.0.4 | lib/jets/router/method_creator.rb |
jets-2.0.3 | lib/jets/router/method_creator.rb |
jets-2.0.1 | lib/jets/router/method_creator.rb |
jets-2.0.0 | lib/jets/router/method_creator.rb |