-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
03fd483
commit 0c6ed78
Showing
11 changed files
with
122 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Pragma | ||
class ResourceGenerator < ::Rails::Generators::NamedBase | ||
source_root File.expand_path("../templates", __FILE__) | ||
|
||
class_option :version, type: :numeric, default: 1, desc: 'The API version to use', aliases: '-v' | ||
|
||
def copy_initializer_file | ||
directory 'resource', "app/resources/api/v#{options['version']}/#{file_name}" | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/contract/base.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Contract | ||
module <%= file_name.camelcase %> | ||
class Base < Pragma::Contract::Base | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/contract/create.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Contract | ||
module <%= file_name.camelcase %> | ||
class Create < Base | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/contract/update.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Contract | ||
module <%= file_name.camelcase %> | ||
class Update < Base | ||
end | ||
end | ||
end | ||
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,8 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module <%= file_name.camelcase %> | ||
class Decorator < Pragma::Decorator::Base | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/operation/create.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Operation | ||
module <%= file_name.camelcase %> | ||
class Create < Pragma::Operation::Create | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/operation/destroy.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Operation | ||
module <%= file_name.camelcase %> | ||
class Destroy < Pragma::Operation::Destroy | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/operation/index.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Operation | ||
module <%= file_name.camelcase %> | ||
class Index < Pragma::Operation::Index | ||
end | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
lib/generators/pragma/templates/resource/operation/update.rb.tt
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,10 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module Operation | ||
module <%= file_name.camelcase %> | ||
class Update < Pragma::Operation::Update | ||
end | ||
end | ||
end | ||
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,29 @@ | ||
module API | ||
module V<%= options['version'] %> | ||
module <%= file_name.camelcase %> | ||
class Policy < Pragma::Policy::Base | ||
class Scope < Pragma::Policy::Base::Scope | ||
def resolve | ||
scope.where('1 = 0') | ||
end | ||
end | ||
|
||
def show? | ||
false | ||
end | ||
|
||
def create? | ||
false | ||
end | ||
|
||
def update? | ||
false | ||
end | ||
|
||
def destroy? | ||
false | ||
end | ||
end | ||
end | ||
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