class Katapult::Generators::WebUIGenerator
Public Instance Methods
add_route()
click to toggle source
# File lib/generators/katapult/web_ui/web_ui_generator.rb, line 20 def add_route route = model_name(:symbols) routes = File.read('config/routes.rb') if routes =~ /^\s+resources #{ route }/ say_status :warn, <<MESSAGE, :red Routes for #{ route } already exist! Not updated. In order to keep existing routes created by the user, the config/routes.rb file is not wiped on model transformation. To have Katapult update the #{ route } route for you, delete it before transforming the application model. MESSAGE elsif web_ui.crud_only? route "resources #{ route }" else route render_partial('_route.rb') end end
create_controller_file()
click to toggle source
# File lib/generators/katapult/web_ui/web_ui_generator.rb, line 16 def create_controller_file template 'controller.rb', File.join('app', 'controllers', "#{ model_name(:variables) }_controller.rb") end
generate_views()
click to toggle source
# File lib/generators/katapult/web_ui/web_ui_generator.rb, line 38 def generate_views Generators::ViewsGenerator.new(web_ui, options).invoke_all end
method_name(name)
click to toggle source
# File lib/generators/katapult/web_ui/web_ui_generator.rb, line 43 def method_name(name) case name when :load_collection then "load_#{model_name :variables}" when :load_object then "load_#{model_name :variable}" when :build then "build_#{model_name :variable}" when :save then "save_#{model_name :variable}" when :params then "#{model_name :variable}_params" when :scope then "#{model_name :variable}_scope" end end
model_name(kind = nil)
click to toggle source
# File lib/generators/katapult/web_ui/web_ui_generator.rb, line 54 def model_name(kind = nil) web_ui.model_name(kind) end
Private Instance Methods
web_ui()
click to toggle source
# File lib/generators/katapult/web_ui/web_ui_generator.rb, line 61 def web_ui @element end