Class: Lotus::Commands::Generate::Action
- Defined in:
- lib/lotus/commands/generate/action.rb
Overview
Constant Summary collapse
- ACTION_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/[\/,#]/
- ROUTE_ENDPOINT_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'#'.freeze
- QUOTED_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/(\"|\'|\\)/
- DEFAULT_HTTP_METHOD =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default HTTP method used when generating an action.
'GET'.freeze
- RESOURCEFUL_HTTP_METHODS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
HTTP methods used when generating resourceful actions.
{ 'Create' => 'POST', 'Update' => 'PATCH', 'Destroy' => 'DELETE' }.freeze
- RESOURCEFUL_ROUTE_URL_SUFFIXES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
For resourceful actions, what to add to the end of the base URL
{ 'Show' => '/:id', 'Update' => '/:id', 'Destroy' => '/:id', 'New' => '/new', 'Edit' => '/:id/edit', }.freeze
Instance Attribute Summary
Attributes inherited from Abstract
Instance Method Summary collapse
-
#initialize(options, application_name, controller_and_action_name) ⇒ Action
constructor
A new instance of Action.
- #map_templates ⇒ Object
- #post_process_templates ⇒ Object
- #template_options ⇒ Object private
Methods inherited from Abstract
Methods included from Generators::Generatable
#add_mapping, #destroy, #generator, #process_templates, #start, #target_path, #template_source_path
Constructor Details
#initialize(options, application_name, controller_and_action_name) ⇒ Action
Returns a new instance of Action.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/lotus/commands/generate/action.rb', line 49 def initialize(, application_name, controller_and_action_name) super() if !environment.container? application_name = File.basename(Dir.pwd) end controller_and_action_name = Utils::String.new(controller_and_action_name).underscore.gsub(QUOTED_NAME, '') *controller_name, action_name = controller_and_action_name.split(ACTION_SEPARATOR) @application_name = Utils::String.new(application_name).classify @controller_name = Utils::String.new(controller_name.join("/")).classify @action_name = Utils::String.new(action_name).classify @controller_pathname = Utils::String.new(@controller_name).underscore assert_application_name! assert_controller_name! assert_action_name! assert_http_method! end |
Instance Method Details
#map_templates ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/lotus/commands/generate/action.rb', line 70 def map_templates add_mapping("action_spec.#{test_framework.framework}.tt", action_spec_path) if skip_view? add_mapping('action_without_view.rb.tt', action_path) else add_mapping('action.rb.tt', action_path) add_mapping('view.rb.tt', view_path) add_mapping('template.tt', template_path) add_mapping("view_spec.#{test_framework.framework}.tt", view_spec_path) end end |
#post_process_templates ⇒ Object
83 84 85 |
# File 'lib/lotus/commands/generate/action.rb', line 83 def post_process_templates generate_route end |
#template_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/lotus/commands/generate/action.rb', line 89 def { app: @application_name, controller: @controller_name, action: @action_name, relative_action_path: relative_action_path, relative_view_path: relative_view_path, template_path: template_path, } end |