Class: OQGraph::Generators::OQGraphGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- OQGraph::Generators::OQGraphGenerator
- Includes:
- Rails::Generators::ResourceHelpers
- Defined in:
- lib/generators/oqgraph/oqgraph_generator.rb
Instance Method Summary collapse
- #create_edge_model ⇒ Object
- #create_edge_table_migration ⇒ Object
- #create_node_model ⇒ Object
- #create_oqgraph_migration ⇒ Object
Instance Method Details
#create_edge_model ⇒ Object
14 15 16 17 18 |
# File 'lib/generators/oqgraph/oqgraph_generator.rb', line 14 def create_edge_model @node_class = file_name.camelize @edge_class = "#{@node_class}Edge" template "graph_edge.rb", File.join('app/models', "#{file_name}_edge.rb") end |
#create_edge_table_migration ⇒ Object
25 26 27 28 |
# File 'lib/generators/oqgraph/oqgraph_generator.rb', line 25 def create_edge_table_migration @edge_table_name = @edge_class.pluralize.underscore migration_template "graph_edge_migration.rb", "db/migrate/create_#{@edge_table_name}" end |
#create_node_model ⇒ Object
20 21 22 23 |
# File 'lib/generators/oqgraph/oqgraph_generator.rb', line 20 def create_node_model @node_class = file_name.camelize template "graph_node.rb", File.join('app/models', "#{file_name}.rb") end |
#create_oqgraph_migration ⇒ Object
30 31 32 33 |
# File 'lib/generators/oqgraph/oqgraph_generator.rb', line 30 def create_oqgraph_migration @oqgraph_table_name = "#{file_name}_oqgraph" migration_template "graph_oqgraph_migration.rb", "db/migrate/create_#{@oqgraph_table_name}" end |