Class: Shogun::Command::Generate

Inherits:
Object
  • Object
show all
Includes:
Architecture
Defined in:
lib/shogun/command/generate.rb

Instance Method Summary collapse

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

#executeObject



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