-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Reed Law
committed
Jun 28, 2014
1 parent
057cd24
commit d4c210d
Showing
3 changed files
with
59 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class EntityGenerator < Rails::Generators::NamedBase | ||
desc "This generator creates an entity file in lib/entities" | ||
source_root File.expand_path('../templates', __FILE__) | ||
|
||
def create_entity_file | ||
create_file "lib/entities/#{file_name}.rb", <<-FILE | ||
class #{class_name} < Entity | ||
end | ||
FILE | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'tilt/handlebars' | ||
|
||
<% if namespaced? -%> | ||
require_dependency "<%= namespaced_path %>/application_controller" | ||
<% end -%> | ||
<% module_namespacing do -%> | ||
class <%= class_name %>Controller < ApplicationController | ||
<% actions.each do |action| -%> | ||
def <%= action %> | ||
template = Tilt.new('app/views/<%= file_name %>/<%= action %>.html.hbs') | ||
render text: template.render | ||
end | ||
<%= "\n" unless action == actions.last -%> | ||
<% end -%> | ||
end | ||
<% end -%> |