Class: Generators::Avo::ResourceGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Generators::Avo::ResourceGenerator
- Defined in:
- lib/generators/avo/resource_generator.rb
Instance Method Summary collapse
- #controller_class ⇒ Object
- #controller_name ⇒ Object
- #create ⇒ Object
- #current_models ⇒ Object
- #resource_class ⇒ Object
- #resource_name ⇒ Object
Instance Method Details
#controller_class ⇒ Object
19 20 21 |
# File 'lib/generators/avo/resource_generator.rb', line 19 def controller_class "Avo::#{class_name.camelize.pluralize}Controller" end |
#controller_name ⇒ Object
27 28 29 |
# File 'lib/generators/avo/resource_generator.rb', line 27 def controller_name "#{plural_name}_controller" end |
#create ⇒ Object
10 11 12 13 |
# File 'lib/generators/avo/resource_generator.rb', line 10 def create template "resource/resource.tt", "app/avo/resources/#{resource_name}.rb" template "resource/controller.tt", "app/controllers/avo/#{controller_name}.rb" end |
#current_models ⇒ Object
31 32 33 34 35 |
# File 'lib/generators/avo/resource_generator.rb', line 31 def current_models ActiveRecord::Base.connection.tables.map do |model| model.capitalize.singularize.camelize end end |
#resource_class ⇒ Object
15 16 17 |
# File 'lib/generators/avo/resource_generator.rb', line 15 def resource_class "#{class_name}Resource" end |
#resource_name ⇒ Object
23 24 25 |
# File 'lib/generators/avo/resource_generator.rb', line 23 def resource_name "#{singular_name}_resource" end |