Class: Jets::Router::MethodCreator
- Inherits:
-
Object
- Object
- Jets::Router::MethodCreator
- Includes:
- Util
- Defined in:
- lib/jets/router/method_creator.rb,
lib/jets/router/method_creator/new.rb,
lib/jets/router/method_creator/code.rb,
lib/jets/router/method_creator/edit.rb,
lib/jets/router/method_creator/root.rb,
lib/jets/router/method_creator/show.rb,
lib/jets/router/method_creator/index.rb,
lib/jets/router/method_creator/generic.rb
Defined Under Namespace
Classes: Code, Edit, Generic, Index, New, Root, Show
Instance Method Summary collapse
-
#create_method(action) ⇒ Object
Examples:.
- #create_root_helper ⇒ Object
- #def_meth(str) ⇒ Object
- #define_url_helper! ⇒ Object
-
#initialize(options, scope) ⇒ MethodCreator
constructor
A new instance of MethodCreator.
Methods included from Util
#get_controller_action, #handle_on!, #join, #underscore
Constructor Details
#initialize(options, scope) ⇒ MethodCreator
Returns a new instance of MethodCreator.
5 6 7 8 |
# File 'lib/jets/router/method_creator.rb', line 5 def initialize(, scope) @options, @scope = , scope @controller, @action = get_controller_action(@options) end |
Instance Method Details
#create_method(action) ⇒ Object
Examples:
posts_path: path: 'posts'
admin_posts_path: prefix: 'admin', path: 'posts'
new_post_path
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/jets/router/method_creator.rb', line 26 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) def_meth(code.path_method) if code.path_method def_meth(code.url_method) if code.url_method end |
#create_root_helper ⇒ Object
40 41 42 43 44 |
# File 'lib/jets/router/method_creator.rb', line 40 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_meth(str) ⇒ Object
46 47 48 |
# File 'lib/jets/router/method_creator.rb', line 46 def def_meth(str) Jets::Router::Helpers::NamedRoutesHelper.class_eval(str) end |
#define_url_helper! ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/jets/router/method_creator.rb', line 10 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 |