Class: Graphgraph::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/graphgraph/install_generator.rb

Constant Summary collapse

CONTROLLERS =
%w(graphgraphs).freeze

Instance Method Summary collapse

Instance Method Details

#copy_viewsObject

source_root File.expand_path(“../templates/”, __FILE__)



35
36
37
# File 'lib/generators/graphgraph/install_generator.rb', line 35

def copy_views
  directory "views/graphgraphs","app/views/#{scope || 'graphgraph'}/graphgraphs/"
end

#create_controllersObject



13
14
15
16
17
18
19
20
# File 'lib/generators/graphgraph/install_generator.rb', line 13

def create_controllers
    @scope_prefix = scope.blank? ? '' : (scope.camelize + '::')
    controllers = options[:controllers] || CONTROLLERS
    controllers.each do |name|
      template "controllers/#{name}_controller.rb",
               "app/controllers/#{scope}/#{name}_controller.rb"
    end
end

#setup_routesObject



22
23
24
25
# File 'lib/generators/graphgraph/install_generator.rb', line 22

def setup_routes
			route("get '#{scope}s/graphgraph' => '#{scope}/graphgraphs#graphgraph'")
		route("post '#{scope}s/graphgraph' => '#{scope}/graphgraphs#graphgraph'")
end