rails_age 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -7
  3. data/README.md +108 -57
  4. data/config/initializers/types.rb +20 -0
  5. data/lib/apache_age/edge.rb +5 -0
  6. data/lib/apache_age/entities/common_methods.rb +6 -0
  7. data/lib/apache_age/entities/edge.rb +4 -3
  8. data/lib/apache_age/entities/node.rb +53 -0
  9. data/lib/apache_age/entities/vertex.rb +1 -1
  10. data/lib/apache_age/node.rb +36 -0
  11. data/lib/apache_age/types/age_type_factory.rb +46 -0
  12. data/lib/apache_age/validators/expected_node_type.rb +17 -0
  13. data/lib/apache_age/validators/unique_node.rb +32 -0
  14. data/lib/apache_age/validators/{vertex_type_validator.rb → vertex_type_validator copy.rb } +2 -1
  15. data/lib/generators/apache_age/edge/edge_generator.rb +4 -2
  16. data/lib/generators/apache_age/edge/templates/edge.rb.tt +3 -3
  17. data/lib/generators/apache_age/{generate_entity_methods.rb → generator_entity_helpers.rb} +7 -4
  18. data/lib/generators/apache_age/generator_resource_helpers.rb +6 -0
  19. data/lib/generators/apache_age/node/node_generator.rb +4 -2
  20. data/lib/generators/apache_age/scaffold_edge/USAGE +16 -0
  21. data/lib/generators/apache_age/scaffold_edge/scaffold_edge_generator.rb +67 -0
  22. data/lib/generators/apache_age/scaffold_edge/scaffold_node_generator.rb +67 -0
  23. data/lib/generators/apache_age/scaffold_edge/templates/controller.rb.tt +50 -0
  24. data/lib/generators/apache_age/scaffold_edge/templates/views/_form.html.erb.tt +47 -0
  25. data/lib/generators/apache_age/scaffold_edge/templates/views/edit.html.erb.tt +12 -0
  26. data/lib/generators/apache_age/scaffold_edge/templates/views/index.html.erb.tt +16 -0
  27. data/lib/generators/apache_age/scaffold_edge/templates/views/new.html.erb.tt +11 -0
  28. data/lib/generators/apache_age/scaffold_edge/templates/views/partial.html.erb.tt +26 -0
  29. data/lib/generators/apache_age/scaffold_edge/templates/views/show.html.erb.tt +10 -0
  30. data/lib/generators/apache_age/scaffold_node/USAGE +16 -0
  31. data/lib/generators/apache_age/scaffold_node/scaffold_node_generator.rb +67 -0
  32. data/lib/generators/apache_age/scaffold_node/templates/controller.rb.tt +50 -0
  33. data/lib/generators/apache_age/scaffold_node/templates/views/_form.html.erb.tt +37 -0
  34. data/lib/generators/apache_age/scaffold_node/templates/views/edit.html.erb.tt +12 -0
  35. data/lib/generators/apache_age/scaffold_node/templates/views/index.html.erb.tt +16 -0
  36. data/lib/generators/apache_age/scaffold_node/templates/views/new.html.erb.tt +11 -0
  37. data/lib/generators/apache_age/scaffold_node/templates/views/partial.html.erb.tt +17 -0
  38. data/lib/generators/apache_age/scaffold_node/templates/views/show.html.erb.tt +10 -0
  39. data/lib/rails_age/version.rb +1 -1
  40. data/lib/rails_age.rb +7 -1
  41. data/lib/tasks/config_types.rake +4 -4
  42. metadata +59 -4
@@ -0,0 +1,67 @@
1
+ # lib/generators/apache_age/scaffold_edge/scaffold_edge_generator.rb
2
+
3
+ require 'rails/generators'
4
+ require 'rails/generators/named_base'
5
+ require 'rails/generators/resource_helpers'
6
+
7
+ module ApacheAge
8
+ class ScaffoldEdgeGenerator < Rails::Generators::NamedBase
9
+ include Rails::Generators::ResourceHelpers
10
+
11
+ desc "Generates an edge, and its controller and views with the given attributes."
12
+
13
+ source_root File.expand_path("templates", __dir__)
14
+
15
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
16
+
17
+ def create_model_file
18
+ invoke 'apache_age:edge', [name] + attributes.collect { |attr| "#{attr.name}:#{attr.type}" }
19
+ end
20
+
21
+ def create_controller_files
22
+ template(
23
+ "controller.rb.tt",
24
+ File.join(Rails.root, "app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
25
+ )
26
+ end
27
+
28
+ def create_route
29
+ route_content = route_text(class_path, file_name)
30
+ inject_into_file(
31
+ File.join(Rails.root, 'config', 'routes.rb'), "\n#{route_content}",
32
+ after: "Rails.application.routes.draw do"
33
+ )
34
+ end
35
+
36
+ def copy_view_files
37
+ available_views.each do |view|
38
+ view_name = view == 'partial' ? "_#{singular_table_name}" : view
39
+ filename = filename_with_extensions(view_name)
40
+ template(
41
+ "views/#{view}.html.erb.tt",
42
+ File.join(Rails.root, "app/views", controller_file_path, filename)
43
+ )
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def available_views
50
+ %w[index edit show new partial _form]
51
+ end
52
+
53
+ def filename_with_extensions(view)
54
+ [view, :html, :erb].compact.join('.')
55
+ end
56
+
57
+ def route_text(class_path, file_name)
58
+ return " resources :#{file_name.pluralize}" if class_path.empty?
59
+
60
+ <<-RUBY
61
+ namespace :#{class_path.join(':')} do
62
+ resources :#{file_name.pluralize}
63
+ end
64
+ RUBY
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,67 @@
1
+ # lib/generators/apache_age/scaffold_node/scaffold_node_generator.rb
2
+
3
+ require 'rails/generators'
4
+ require 'rails/generators/named_base'
5
+ require 'rails/generators/resource_helpers'
6
+
7
+ module ApacheAge
8
+ class ScaffoldNodeGenerator < Rails::Generators::NamedBase
9
+ include Rails::Generators::ResourceHelpers
10
+
11
+ desc "Generates a node, and its controller and views with the given attributes."
12
+
13
+ source_root File.expand_path("templates", __dir__)
14
+
15
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
16
+
17
+ def create_model_file
18
+ invoke 'apache_age:edge', [name] + attributes.collect { |attr| "#{attr.name}:#{attr.type}" }
19
+ end
20
+
21
+ def create_controller_files
22
+ template(
23
+ "controller.rb.tt",
24
+ File.join(Rails.root, "app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
25
+ )
26
+ end
27
+
28
+ def create_route
29
+ route_content = route_text(class_path, file_name)
30
+ inject_into_file(
31
+ File.join(Rails.root, 'config', 'routes.rb'), "\n#{route_content}",
32
+ after: "Rails.application.routes.draw do"
33
+ )
34
+ end
35
+
36
+ def copy_view_files
37
+ available_views.each do |view|
38
+ view_name = view == 'partial' ? "_#{singular_table_name}" : view
39
+ filename = filename_with_extensions(view_name)
40
+ template(
41
+ "views/#{view}.html.erb.tt",
42
+ File.join(Rails.root, "app/views", controller_file_path, filename)
43
+ )
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def available_views
50
+ %w[index edit show new partial _form]
51
+ end
52
+
53
+ def filename_with_extensions(view)
54
+ [view, :html, :erb].compact.join('.')
55
+ end
56
+
57
+ def route_text(class_path, file_name)
58
+ return " resources :#{file_name.pluralize}" if class_path.empty?
59
+
60
+ <<-RUBY
61
+ namespace :#{class_path.join(':')} do
62
+ resources :#{file_name.pluralize}
63
+ end
64
+ RUBY
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,50 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ before_action :set_<%= singular_table_name %>, only: %i[show edit update destroy]
3
+
4
+ def index
5
+ @<%= plural_table_name %> = <%= class_name %>.all
6
+ end
7
+
8
+ def show
9
+ end
10
+
11
+ def new
12
+ @<%= singular_table_name %> = <%= class_name %>.new
13
+ end
14
+
15
+ def edit
16
+ end
17
+
18
+ def create
19
+ @<%= singular_table_name %> = <%= class_name %>.new(<%= singular_table_name %>_params)
20
+
21
+ if @<%= singular_table_name %>.save
22
+ redirect_to @<%= singular_table_name %>, notice: '<%= human_name %> was successfully created.'
23
+ else
24
+ render :new
25
+ end
26
+ end
27
+
28
+ def update
29
+ if @<%= singular_table_name %>.update(<%= singular_table_name %>_params)
30
+ redirect_to @<%= singular_table_name %>, notice: '<%= human_name %> was successfully updated.'
31
+ else
32
+ render :edit
33
+ end
34
+ end
35
+
36
+ def destroy
37
+ @<%= singular_table_name %>.destroy
38
+ redirect_to <%= index_helper %>_url, notice: '<%= human_name %> was successfully destroyed.'
39
+ end
40
+
41
+ private
42
+
43
+ def set_<%= singular_table_name %>
44
+ @<%= singular_table_name %> = <%= class_name %>.find(params[:id])
45
+ end
46
+
47
+ def <%= singular_table_name %>_params
48
+ params.require(:<%= singular_table_name %>).permit(<%= (attributes + %i[start_id end_id]).map { |attr| ":#{attr.name}" }.join(', ') %>)
49
+ end
50
+ end
@@ -0,0 +1,47 @@
1
+ <%%= form_with(model: <%= model_resource_name %>) do |form| %>
2
+ <%% if <%= singular_table_name %>.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <ul>
7
+ <%% <%= singular_table_name %>.errors.each do |error| %>
8
+ <li><%%= error.full_message %></li>
9
+ <%% end %>
10
+ </ul>
11
+ </div>
12
+ <%% end %>
13
+
14
+ <% attributes.each do |attribute| -%>
15
+ <div>
16
+ <% if attribute.password_digest? -%>
17
+ <%%= form.label :password, style: "display: block" %>
18
+ <%%= form.password_field :password %>
19
+ </div>
20
+
21
+ <div>
22
+ <%%= form.label :password_confirmation, style: "display: block" %>
23
+ <%%= form.password_field :password_confirmation %>
24
+ <% elsif attribute.attachments? -%>
25
+ <%%= form.label :<%= attribute.column_name %>, style: "display: block" %>
26
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true %>
27
+ <% else -%>
28
+ <%%= form.label :<%= attribute.column_name %>, style: "display: block" %>
29
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %> %>
30
+ <% end -%>
31
+ </div>
32
+
33
+ <% end -%>
34
+ <div>
35
+ <%%= form.label :start_node, style: "display: block" %>
36
+ <%%= form.collection_select(:start_id, ApacheAge::Node.all, :id, :display, prompt: 'Select a Start-Node') %>
37
+ </div>
38
+
39
+ <div>
40
+ <%%= form.label :end_node, style: "display: block" %>
41
+ <%%= form.collection_select(:end_id, ApacheAge::Node.all, :id, :display, prompt: 'Select an End-Node') %>
42
+ </div>
43
+
44
+ <div>
45
+ <%%= form.submit %>
46
+ </div>
47
+ <%% end %>
@@ -0,0 +1,12 @@
1
+ <%% content_for :title, "Editing <%= human_name.downcase %>" %>
2
+
3
+ <h1>Editing <%= human_name.downcase %></h1>
4
+
5
+ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %> %> |
11
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
12
+ </div>
@@ -0,0 +1,16 @@
1
+ <p style="color: green"><%%= notice %></p>
2
+
3
+ <%% content_for :title, "<%= human_name.pluralize %>" %>
4
+
5
+ <h1><%= human_name.pluralize %></h1>
6
+
7
+ <div id="<%= plural_table_name %>">
8
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
9
+ <%%= render '<%= singular_table_name %>', <%= singular_table_name %>: <%= singular_table_name %> %>
10
+ <p>
11
+ <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %> %>
12
+ </p>
13
+ <%% end %>
14
+ </div>
15
+
16
+ <%%= link_to "New <%= human_name.downcase %>", <%= new_helper(type: :path) %> %>
@@ -0,0 +1,11 @@
1
+ <%% content_for :title, "New <%= human_name.downcase %>" %>
2
+
3
+ <h1>New <%= human_name.downcase %></h1>
4
+
5
+ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
11
+ </div>
@@ -0,0 +1,26 @@
1
+ <div id="<%%= dom_id <%= singular_table_name %> %>">
2
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
3
+ <p>
4
+ <strong><%= attribute.human_name %>:</strong>
5
+ <% if attribute.attachment? -%>
6
+ <%%= link_to <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %>
7
+ <% elsif attribute.attachments? -%>
8
+ <%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
9
+ <div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
10
+ <%% end %>
11
+ <% else -%>
12
+ <%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
13
+ <% end -%>
14
+ </p>
15
+
16
+ <% end -%>
17
+ <p>
18
+ <strong>Start-Node:</strong>
19
+ <%%= <%= singular_table_name %>.start_node.display %>
20
+ </p>
21
+
22
+ <p>
23
+ <strong>End-Node:</strong>
24
+ <%%= <%= singular_table_name %>.end_node.display %>
25
+ </p>
26
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%%= notice %></p>
2
+
3
+ <%%= render '<%= singular_table_name %>', <%= singular_table_name %>: @<%= singular_table_name %> %>
4
+
5
+ <div>
6
+ <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %> %> |
7
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
8
+
9
+ <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete %>
10
+ </div>
@@ -0,0 +1,16 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ bin/rails generate apache_age:scaffold_node Pet name birthdate:date
6
+
7
+ This will create:
8
+ create app/nodes/pet.rb
9
+ modified: config/initializers/types.rb
10
+ create app/controllers/pets_controller.rb
11
+ route resources :pets
12
+ create app/views/pets/index.html.erb
13
+ create app/views/pets/edit.html.erb
14
+ create app/views/pets/show.html.erb
15
+ create app/views/pets/new.html.erb
16
+ create app/views/pets/partial.html.erb
@@ -0,0 +1,67 @@
1
+ # lib/generators/apache_age/scaffold_node/scaffold_node_generator.rb
2
+
3
+ require 'rails/generators'
4
+ require 'rails/generators/named_base'
5
+ require 'rails/generators/resource_helpers'
6
+
7
+ module ApacheAge
8
+ class ScaffoldNodeGenerator < Rails::Generators::NamedBase
9
+ include Rails::Generators::ResourceHelpers
10
+
11
+ desc "Generates a node, and its controller and views with the given attributes."
12
+
13
+ source_root File.expand_path("templates", __dir__)
14
+
15
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
16
+
17
+ def create_model_file
18
+ invoke 'apache_age:node', [name] + attributes.collect { |attr| "#{attr.name}:#{attr.type}" }
19
+ end
20
+
21
+ def create_controller_files
22
+ template(
23
+ "controller.rb.tt",
24
+ File.join(Rails.root, "app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
25
+ )
26
+ end
27
+
28
+ def create_route
29
+ route_content = route_text(class_path, file_name)
30
+ inject_into_file(
31
+ File.join(Rails.root, 'config', 'routes.rb'), "\n#{route_content}",
32
+ after: "Rails.application.routes.draw do"
33
+ )
34
+ end
35
+
36
+ def copy_view_files
37
+ available_views.each do |view|
38
+ view_name = view == 'partial' ? "_#{singular_table_name}" : view
39
+ filename = filename_with_extensions(view_name)
40
+ template(
41
+ "views/#{view}.html.erb.tt",
42
+ File.join(Rails.root, "app/views", controller_file_path, filename)
43
+ )
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def available_views
50
+ %w[index edit show new partial _form]
51
+ end
52
+
53
+ def filename_with_extensions(view)
54
+ [view, :html, :erb].compact.join('.')
55
+ end
56
+
57
+ def route_text(class_path, file_name)
58
+ return " resources :#{file_name.pluralize}" if class_path.empty?
59
+
60
+ <<-RUBY
61
+ namespace :#{class_path.join(':')} do
62
+ resources :#{file_name.pluralize}
63
+ end
64
+ RUBY
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,50 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ before_action :set_<%= singular_table_name %>, only: %i[show edit update destroy]
3
+
4
+ def index
5
+ @<%= plural_table_name %> = <%= class_name %>.all
6
+ end
7
+
8
+ def show
9
+ end
10
+
11
+ def new
12
+ @<%= singular_table_name %> = <%= class_name %>.new
13
+ end
14
+
15
+ def edit
16
+ end
17
+
18
+ def create
19
+ @<%= singular_table_name %> = <%= class_name %>.new(<%= singular_table_name %>_params)
20
+
21
+ if @<%= singular_table_name %>.save
22
+ redirect_to @<%= singular_table_name %>, notice: '<%= human_name %> was successfully created.'
23
+ else
24
+ render :new
25
+ end
26
+ end
27
+
28
+ def update
29
+ if @<%= singular_table_name %>.update(<%= singular_table_name %>_params)
30
+ redirect_to @<%= singular_table_name %>, notice: '<%= human_name %> was successfully updated.'
31
+ else
32
+ render :edit
33
+ end
34
+ end
35
+
36
+ def destroy
37
+ @<%= singular_table_name %>.destroy
38
+ redirect_to <%= index_helper %>_url, notice: '<%= human_name %> was successfully destroyed.'
39
+ end
40
+
41
+ private
42
+
43
+ def set_<%= singular_table_name %>
44
+ @<%= singular_table_name %> = <%= class_name %>.find(params[:id])
45
+ end
46
+
47
+ def <%= singular_table_name %>_params
48
+ params.require(:<%= singular_table_name %>).permit(<%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>)
49
+ end
50
+ end
@@ -0,0 +1,37 @@
1
+ <%%= form_with(model: <%= model_resource_name %>) do |form| %>
2
+ <%% if <%= singular_table_name %>.errors.any? %>
3
+ <div style="color: red">
4
+ <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <ul>
7
+ <%% <%= singular_table_name %>.errors.each do |error| %>
8
+ <li><%%= error.full_message %></li>
9
+ <%% end %>
10
+ </ul>
11
+ </div>
12
+ <%% end %>
13
+
14
+ <% attributes.each do |attribute| -%>
15
+ <div>
16
+ <% if attribute.password_digest? -%>
17
+ <%%= form.label :password, style: "display: block" %>
18
+ <%%= form.password_field :password %>
19
+ </div>
20
+
21
+ <div>
22
+ <%%= form.label :password_confirmation, style: "display: block" %>
23
+ <%%= form.password_field :password_confirmation %>
24
+ <% elsif attribute.attachments? -%>
25
+ <%%= form.label :<%= attribute.column_name %>, style: "display: block" %>
26
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true %>
27
+ <% else -%>
28
+ <%%= form.label :<%= attribute.column_name %>, style: "display: block" %>
29
+ <%%= form.<%= attribute.field_type %> :<%= attribute.column_name %> %>
30
+ <% end -%>
31
+ </div>
32
+
33
+ <% end -%>
34
+ <div>
35
+ <%%= form.submit %>
36
+ </div>
37
+ <%% end %>
@@ -0,0 +1,12 @@
1
+ <%% content_for :title, "Editing <%= human_name.downcase %>" %>
2
+
3
+ <h1>Editing <%= human_name.downcase %></h1>
4
+
5
+ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %> %> |
11
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
12
+ </div>
@@ -0,0 +1,16 @@
1
+ <p style="color: green"><%%= notice %></p>
2
+
3
+ <%% content_for :title, "<%= human_name.pluralize %>" %>
4
+
5
+ <h1><%= human_name.pluralize %></h1>
6
+
7
+ <div id="<%= plural_table_name %>">
8
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
9
+ <%%= render '<%= singular_table_name %>', <%= singular_table_name %>: <%= singular_table_name %> %>
10
+ <p>
11
+ <%%= link_to "Show this <%= human_name.downcase %>", <%= model_resource_name(singular_table_name) %> %>
12
+ </p>
13
+ <%% end %>
14
+ </div>
15
+
16
+ <%%= link_to "New <%= human_name.downcase %>", <%= new_helper(type: :path) %> %>
@@ -0,0 +1,11 @@
1
+ <%% content_for :title, "New <%= human_name.downcase %>" %>
2
+
3
+ <h1>New <%= human_name.downcase %></h1>
4
+
5
+ <%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
6
+
7
+ <br>
8
+
9
+ <div>
10
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
11
+ </div>
@@ -0,0 +1,17 @@
1
+ <div id="<%%= dom_id <%= singular_table_name %> %>">
2
+ <% attributes.reject(&:password_digest?).each do |attribute| -%>
3
+ <p>
4
+ <strong><%= attribute.human_name %>:</strong>
5
+ <% if attribute.attachment? -%>
6
+ <%%= link_to <%= singular_table_name %>.<%= attribute.column_name %>.filename, <%= singular_table_name %>.<%= attribute.column_name %> if <%= singular_table_name %>.<%= attribute.column_name %>.attached? %>
7
+ <% elsif attribute.attachments? -%>
8
+ <%% <%= singular_table_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
9
+ <div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
10
+ <%% end %>
11
+ <% else -%>
12
+ <%%= <%= singular_table_name %>.<%= attribute.column_name %> %>
13
+ <% end -%>
14
+ </p>
15
+
16
+ <% end -%>
17
+ </div>
@@ -0,0 +1,10 @@
1
+ <p style="color: green"><%%= notice %></p>
2
+
3
+ <%%= render '<%= singular_table_name %>', <%= singular_table_name %>: @<%= singular_table_name %> %>
4
+
5
+ <div>
6
+ <%%= link_to "Edit this <%= human_name.downcase %>", <%= edit_helper(type: :path) %> %> |
7
+ <%%= link_to "Back to <%= human_name.pluralize.downcase %>", <%= index_helper(type: :path) %> %>
8
+
9
+ <%%= button_to "Destroy this <%= human_name.downcase %>", <%= model_resource_name(prefix: "@") %>, method: :delete %>
10
+ </div>
@@ -1,3 +1,3 @@
1
1
  module RailsAge
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.3'
3
3
  end
data/lib/rails_age.rb CHANGED
@@ -8,10 +8,16 @@ end
8
8
  module ApacheAge
9
9
  require 'apache_age/entities/class_methods'
10
10
  require 'apache_age/entities/common_methods'
11
- require 'apache_age/entities/edge'
12
11
  require 'apache_age/entities/entity'
13
12
  require 'apache_age/entities/vertex'
13
+ require 'apache_age/entities/node'
14
+ require 'apache_age/entities/edge'
15
+ require 'apache_age/node'
16
+ require 'apache_age/edge'
17
+ require 'apache_age/validators/expected_node_type'
18
+ require 'apache_age/validators/unique_node'
14
19
  require 'apache_age/validators/unique_edge'
15
20
  require 'apache_age/validators/unique_vertex'
21
+ require 'apache_age/types/age_type_factory'
16
22
  require 'apache_age/types/age_type_generator'
17
23
  end
@@ -17,16 +17,16 @@ namespace :apache_age do
17
17
  RUBY
18
18
  node_type_content =
19
19
  <<-RUBY
20
- require_dependency 'apache_age/entities/vertex'
20
+ require_dependency 'apache_age/node'
21
21
  ActiveModel::Type.register(
22
- :vertex, ApacheAge::Types::AgeTypeGenerator.create_type_for(ApacheAge::Entities::Vertex)
22
+ :node, ApacheAge::Types::AgeTypeGenerator.create_type_for(ApacheAge::Node)
23
23
  )
24
24
  RUBY
25
25
  edge_type_content =
26
26
  <<-RUBY
27
- require_dependency 'apache_age/entities/edge'
27
+ require_dependency 'apache_age/edge'
28
28
  ActiveModel::Type.register(
29
- :edge, ApacheAge::Types::AgeTypeGenerator.create_type_for(ApacheAge::Entities::Edge)
29
+ :edge, ApacheAge::Types::AgeTypeGenerator.create_type_for(ApacheAge::Edge)
30
30
  )
31
31
  RUBY
32
32