Class: Shogun::Command::Generate
- Inherits:
-
Object
- Object
- Shogun::Command::Generate
- Includes:
- Architecture
- Defined in:
- lib/shogun/command/generate.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(namespace, resource, *parameters) ⇒ Generate
constructor
A new instance of Generate.
Constructor Details
#initialize(namespace, resource, *parameters) ⇒ Generate
Returns a new instance of Generate.
6 7 8 9 10 |
# File 'lib/shogun/command/generate.rb', line 6 def initialize(namespace, resource, *parameters) @namespace = namespace @resource = resource @parameters = parameters end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/shogun/command/generate.rb', line 12 def execute architecture(source: scaffold_directory, destination: namespace_directory) do |architect| architect.copy(file: "resource.rb", as: "#{resource}.rb", context: context) architect.create(directory: architect.destination(resource)) architect.within(source: "resource", destination: resource) do |scope| scope.copy(file: "endpoint.rb", context: context) scope.copy(file: "model.rb", context: context) scope.copy(file: "null.rb", context: context) scope.copy(file: "presenter.rb", context: context) subresource(scope, "show") subresource(scope, "list") subresource(scope, "create") subresource(scope, "update") subresource(scope, "destroy") end end end |