light-services 0.6.3 → 2.0.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/config/rubocop_linter_action.yml +4 -0
- data/.github/workflows/ci.yml +63 -0
- data/.gitignore +11 -4
- data/.rspec +1 -0
- data/.rubocop.yml +22 -8
- data/CHANGELOG.md +1 -0
- data/CODE_OF_CONDUCT.md +55 -30
- data/Gemfile +16 -2
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +1 -1
- data/README.md +3 -149
- data/Rakefile +2 -2
- data/bin/console +4 -4
- data/lib/light/services.rb +4 -7
- data/lib/light/services/base.rb +151 -30
- data/lib/light/services/base_with_context.rb +33 -0
- data/lib/light/services/class_based_collection/base.rb +88 -0
- data/lib/light/services/class_based_collection/mount.rb +33 -0
- data/lib/light/services/collection/arguments.rb +34 -0
- data/lib/light/services/collection/base.rb +55 -0
- data/lib/light/services/collection/outputs.rb +16 -0
- data/lib/light/services/config.rb +63 -0
- data/lib/light/services/exceptions.rb +3 -2
- data/lib/light/services/messages.rb +67 -45
- data/lib/light/services/settings/argument.rb +50 -0
- data/lib/light/services/settings/output.rb +34 -0
- data/lib/light/services/settings/step.rb +77 -0
- data/lib/light/services/version.rb +1 -1
- data/light-services.gemspec +21 -25
- metadata +28 -122
- data/.codeclimate.yml +0 -18
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -33
- data/Appraisals +0 -13
- data/gemfiles/rails_5_0.gemfile +0 -7
- data/gemfiles/rails_5_0.gemfile.lock +0 -151
- data/gemfiles/rails_5_1.gemfile +0 -7
- data/gemfiles/rails_5_1.gemfile.lock +0 -151
- data/gemfiles/rails_5_2.gemfile +0 -7
- data/gemfiles/rails_5_2.gemfile.lock +0 -159
- data/lib/light/services/callbacks.rb +0 -54
- data/lib/light/services/outputs.rb +0 -70
- data/lib/light/services/parameters.rb +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38e4a0f496e63ba78279cf3f1f1b671e838eb1509f4c59f4ee9694c831d64c13
|
4
|
+
data.tar.gz: 8019b013bcef53aa1e9be21818dcb0ab21095d4f1db539b6c891967dc22afabd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f9f99835b0151b1f98016ad4af7767b17e49c3d65a1e991fe8522055a17f58301c183706bc30e2cebc40bd94990d21da70f66f01b17e104b2ed08c56a8a27e
|
7
|
+
data.tar.gz: e2d2b02ca50631518a02329d4b439f253e59ce648cdb4e37448b7a43209a6d2379272c083516862e0dbe38e8999e6419f2d9ece538f0d8a4a15e73e292211dba
|
@@ -0,0 +1,63 @@
|
|
1
|
+
name: CI
|
2
|
+
on: push
|
3
|
+
|
4
|
+
jobs:
|
5
|
+
rubocop:
|
6
|
+
name: Rubocop
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
steps:
|
9
|
+
- name: Git Checkout
|
10
|
+
uses: actions/checkout@v2
|
11
|
+
|
12
|
+
- name: Rubocop
|
13
|
+
uses: andrewmcodes/rubocop-linter-action@v3.2.0
|
14
|
+
env:
|
15
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
16
|
+
|
17
|
+
rspec:
|
18
|
+
name: RSpec
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby: [2.5, 2.6, 2.7, head, debug]
|
23
|
+
steps:
|
24
|
+
- name: Git Checkout
|
25
|
+
uses: actions/checkout@v2
|
26
|
+
|
27
|
+
- name: Install dependencies
|
28
|
+
run: sudo apt-get install libsqlite3-dev
|
29
|
+
|
30
|
+
- name: Setup Ruby
|
31
|
+
uses: ruby/setup-ruby@v1.38.0
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: true
|
35
|
+
|
36
|
+
- name: RSpec
|
37
|
+
run: bundle exec rspec
|
38
|
+
|
39
|
+
codecov:
|
40
|
+
name: Code Coverage
|
41
|
+
runs-on: ubuntu-latest
|
42
|
+
env:
|
43
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
44
|
+
steps:
|
45
|
+
- name: Git Checkout
|
46
|
+
uses: actions/checkout@v2
|
47
|
+
|
48
|
+
- name: Install dependencies
|
49
|
+
run: sudo apt-get install libsqlite3-dev
|
50
|
+
|
51
|
+
- name: Setup Ruby
|
52
|
+
uses: ruby/setup-ruby@v1.38.0
|
53
|
+
with:
|
54
|
+
ruby-version: head
|
55
|
+
bundler-cache: true
|
56
|
+
|
57
|
+
- name: RSpec
|
58
|
+
run: bundle exec rspec
|
59
|
+
|
60
|
+
- name: Code Coverage
|
61
|
+
uses: codecov/codecov-action@v1
|
62
|
+
with:
|
63
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
data/.gitignore
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
# Common
|
1
2
|
/.bundle/
|
2
3
|
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
4
|
/_yardoc/
|
5
5
|
/coverage/
|
6
6
|
/doc/
|
@@ -8,6 +8,13 @@
|
|
8
8
|
/spec/reports/
|
9
9
|
/tmp/
|
10
10
|
/.idea/
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
# RSpec failure tracking
|
13
|
+
.rspec_status
|
14
|
+
|
15
|
+
# Ignore IDE files
|
16
|
+
/.idea
|
17
|
+
*.iml
|
18
|
+
|
19
|
+
# Ignore gem files
|
20
|
+
*.gem
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,16 +1,30 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
- rubocop-performance
|
4
|
+
|
1
5
|
AllCops:
|
2
|
-
|
6
|
+
NewCops: enable
|
7
|
+
|
8
|
+
Layout/MultilineMethodCallIndentation:
|
9
|
+
EnforcedStyle: indented
|
10
|
+
|
11
|
+
Metrics/BlockLength:
|
12
|
+
Exclude:
|
13
|
+
- spec/**/*_spec.rb
|
14
|
+
|
15
|
+
Security/Eval:
|
16
|
+
Exclude:
|
17
|
+
- spec/light/services/error_spec.rb
|
3
18
|
|
4
19
|
Style/Documentation:
|
5
20
|
Enabled: false
|
6
21
|
|
7
|
-
Style/
|
8
|
-
|
9
|
-
- 'spec/**/*'
|
22
|
+
Style/StringLiterals:
|
23
|
+
EnforcedStyle: double_quotes
|
10
24
|
|
11
|
-
|
12
|
-
|
25
|
+
Style/GuardClause:
|
26
|
+
Enabled: false
|
13
27
|
|
14
|
-
|
28
|
+
Style/ClassAndModuleChildren:
|
15
29
|
Exclude:
|
16
|
-
-
|
30
|
+
- spec/data/services/**/*.rb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Changelog
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,24 +1,41 @@
|
|
1
|
-
# Contributor Code of Conduct
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
2
|
|
3
|
-
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
3
|
+
## Our Pledge
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
12
22
|
|
13
23
|
Examples of unacceptable behavior by participants include:
|
14
24
|
|
15
|
-
* The use of sexualized language or imagery
|
16
|
-
|
17
|
-
* Trolling
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
18
28
|
* Public or private harassment
|
19
|
-
* Publishing
|
20
|
-
|
21
|
-
* Other
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
22
39
|
|
23
40
|
Project maintainers have the right and responsibility to remove, edit, or
|
24
41
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
@@ -26,24 +43,32 @@ that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
43
|
permanently any contributor for other behaviors that they deem inappropriate,
|
27
44
|
threatening, offensive, or harmful.
|
28
45
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
33
54
|
|
34
|
-
|
35
|
-
when an individual is representing the project or its community.
|
55
|
+
## Enforcement
|
36
56
|
|
37
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting
|
58
|
+
reported by contacting the project team at emelianenko.web@gmail.com. All
|
39
59
|
complaints will be reviewed and investigated and will result in a response that
|
40
|
-
is deemed necessary and appropriate to the circumstances.
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
-
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
43
69
|
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
-
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
47
72
|
|
48
|
-
[homepage]:
|
49
|
-
[version]:
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
|
-
# Specify your gem's dependencies in light-services.gemspec
|
6
5
|
gemspec
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
gem "activerecord", "~> 6.0"
|
9
|
+
gem "database_cleaner-active_record", "~> 1.8"
|
10
|
+
gem "sqlite3", "~> 1.4"
|
11
|
+
|
12
|
+
gem "codecov", "~> 0.1.17"
|
13
|
+
gem "rake", "~> 13.0"
|
14
|
+
gem "rspec", "~> 3.9"
|
15
|
+
gem "simplecov", "~> 0.18"
|
16
|
+
|
17
|
+
gem "rubocop", "~> 0.86", require: false
|
18
|
+
gem "rubocop-performance", "~> 1.6", require: false
|
19
|
+
gem "rubocop-rspec", "~> 1.40", require: false
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
light-services (2.0.0.rc2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (6.1.4)
|
10
|
+
activesupport (= 6.1.4)
|
11
|
+
activerecord (6.1.4)
|
12
|
+
activemodel (= 6.1.4)
|
13
|
+
activesupport (= 6.1.4)
|
14
|
+
activesupport (6.1.4)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 1.6, < 2)
|
17
|
+
minitest (>= 5.1)
|
18
|
+
tzinfo (~> 2.0)
|
19
|
+
zeitwerk (~> 2.3)
|
20
|
+
ast (2.4.2)
|
21
|
+
codecov (0.1.21)
|
22
|
+
json
|
23
|
+
simplecov
|
24
|
+
concurrent-ruby (1.1.9)
|
25
|
+
database_cleaner (1.99.0)
|
26
|
+
database_cleaner-active_record (1.99.0)
|
27
|
+
activerecord
|
28
|
+
database_cleaner (~> 1.99.0)
|
29
|
+
diff-lcs (1.4.4)
|
30
|
+
docile (1.4.0)
|
31
|
+
i18n (1.8.10)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
json (2.5.1)
|
34
|
+
minitest (5.14.4)
|
35
|
+
parallel (1.20.1)
|
36
|
+
parser (3.0.2.0)
|
37
|
+
ast (~> 2.4.1)
|
38
|
+
rainbow (3.0.0)
|
39
|
+
rake (13.0.6)
|
40
|
+
regexp_parser (2.1.1)
|
41
|
+
rexml (3.2.5)
|
42
|
+
rspec (3.10.0)
|
43
|
+
rspec-core (~> 3.10.0)
|
44
|
+
rspec-expectations (~> 3.10.0)
|
45
|
+
rspec-mocks (~> 3.10.0)
|
46
|
+
rspec-core (3.10.1)
|
47
|
+
rspec-support (~> 3.10.0)
|
48
|
+
rspec-expectations (3.10.1)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.10.0)
|
51
|
+
rspec-mocks (3.10.2)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.10.0)
|
54
|
+
rspec-support (3.10.2)
|
55
|
+
rubocop (0.93.1)
|
56
|
+
parallel (~> 1.10)
|
57
|
+
parser (>= 2.7.1.5)
|
58
|
+
rainbow (>= 2.2.2, < 4.0)
|
59
|
+
regexp_parser (>= 1.8)
|
60
|
+
rexml
|
61
|
+
rubocop-ast (>= 0.6.0)
|
62
|
+
ruby-progressbar (~> 1.7)
|
63
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
64
|
+
rubocop-ast (1.8.0)
|
65
|
+
parser (>= 3.0.1.1)
|
66
|
+
rubocop-performance (1.10.2)
|
67
|
+
rubocop (>= 0.90.0, < 2.0)
|
68
|
+
rubocop-ast (>= 0.4.0)
|
69
|
+
rubocop-rspec (1.44.1)
|
70
|
+
rubocop (~> 0.87)
|
71
|
+
rubocop-ast (>= 0.7.1)
|
72
|
+
ruby-progressbar (1.11.0)
|
73
|
+
simplecov (0.21.2)
|
74
|
+
docile (~> 1.1)
|
75
|
+
simplecov-html (~> 0.11)
|
76
|
+
simplecov_json_formatter (~> 0.1)
|
77
|
+
simplecov-html (0.12.3)
|
78
|
+
simplecov_json_formatter (0.1.3)
|
79
|
+
sqlite3 (1.4.2)
|
80
|
+
tzinfo (2.0.4)
|
81
|
+
concurrent-ruby (~> 1.0)
|
82
|
+
unicode-display_width (1.7.0)
|
83
|
+
zeitwerk (2.4.2)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
ruby
|
87
|
+
|
88
|
+
DEPENDENCIES
|
89
|
+
activerecord (~> 6.0)
|
90
|
+
codecov (~> 0.1.17)
|
91
|
+
database_cleaner-active_record (~> 1.8)
|
92
|
+
light-services!
|
93
|
+
rake (~> 13.0)
|
94
|
+
rspec (~> 3.9)
|
95
|
+
rubocop (~> 0.86)
|
96
|
+
rubocop-performance (~> 1.6)
|
97
|
+
rubocop-rspec (~> 1.40)
|
98
|
+
simplecov (~> 0.18)
|
99
|
+
sqlite3 (~> 1.4)
|
100
|
+
|
101
|
+
BUNDLED WITH
|
102
|
+
2.1.4
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,150 +1,4 @@
|
|
1
|
-
# Light
|
2
|
-
|
3
|
-
[![
|
4
|
-
[![Code Climate](https://codeclimate.com/github/light-ruby/light-services/badges/gpa.svg)](https://codeclimate.com/github/light-ruby/light-services)
|
5
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/ed8713a891f19318bd7c/test_coverage)](https://codeclimate.com/github/light-ruby/light-services/test_coverage)
|
6
|
-
|
7
|
-
Implementation of Service Object Pattern for Ruby/Rails. Compatible with Rails 5.1 and 5.0, 4.2, 4.1, 4.0.
|
8
|
-
|
9
|
-
Service Object Pattern – What is it? Check it here:
|
10
|
-
- [Wikipedia](https://en.wikipedia.org/wiki/Service_layer_pattern)
|
11
|
-
- [Essential RubyOnRails patterns — part 1: Service Objects](https://medium.com/selleo/essential-rubyonrails-patterns-part-1-service-objects-1af9f9573ca1)
|
12
|
-
|
13
|
-
## Installation
|
14
|
-
|
15
|
-
Add this line to your application's Gemfile:
|
16
|
-
|
17
|
-
```ruby
|
18
|
-
gem 'light-services', '~> 0.6'
|
19
|
-
```
|
20
|
-
|
21
|
-
And then execute:
|
22
|
-
|
23
|
-
$ bundle
|
24
|
-
|
25
|
-
Or install it yourself as:
|
26
|
-
|
27
|
-
$ gem install light-service
|
28
|
-
|
29
|
-
## Usage
|
30
|
-
|
31
|
-
#### Examples of usage:
|
32
|
-
|
33
|
-
**Change state of the record:**
|
34
|
-
```ruby
|
35
|
-
class Painting::Publish < ApplicationService
|
36
|
-
# Parameters
|
37
|
-
param :painting, type: Painting
|
38
|
-
param :user, type: User
|
39
|
-
|
40
|
-
# Callbacks
|
41
|
-
before :authorize
|
42
|
-
after :send_email_notification
|
43
|
-
|
44
|
-
def run
|
45
|
-
painting.publish!
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def authorize
|
51
|
-
pundit_authorize!(painting, user, :publish?)
|
52
|
-
end
|
53
|
-
|
54
|
-
def send_email_notification
|
55
|
-
PaintingMailer.publish_email(painting).deliver_now
|
56
|
-
end
|
57
|
-
end
|
58
|
-
```
|
59
|
-
|
60
|
-
**Create a new record:**
|
61
|
-
```ruby
|
62
|
-
class Owner::Create < ApplicationService
|
63
|
-
# Parameters
|
64
|
-
param :params, type: ActionController::Parameters
|
65
|
-
param :user, type: User
|
66
|
-
|
67
|
-
# Outputs
|
68
|
-
output :owner
|
69
|
-
|
70
|
-
# Callbacks
|
71
|
-
before :assign_attributes
|
72
|
-
before :authorize
|
73
|
-
before :validate
|
74
|
-
|
75
|
-
def run
|
76
|
-
owner.save!
|
77
|
-
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def assign_attributes
|
82
|
-
self.owner = Owner.new(owner_params)
|
83
|
-
end
|
84
|
-
|
85
|
-
def authorize
|
86
|
-
pundit_authorize!(owner, user, :create?)
|
87
|
-
end
|
88
|
-
|
89
|
-
def validate
|
90
|
-
return if owner.valid?
|
91
|
-
errors.from_record(owner)
|
92
|
-
end
|
93
|
-
|
94
|
-
def owner_params
|
95
|
-
params
|
96
|
-
.require(:owner)
|
97
|
-
.permit(:name)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
```
|
101
|
-
|
102
|
-
**Integration with Pundit:**
|
103
|
-
```ruby
|
104
|
-
class ApplicationService < Light::Services::Base
|
105
|
-
def pundit_authorize!(record, user, action = nil)
|
106
|
-
action = convert_action(action, :show?)
|
107
|
-
policy = Pundit.policy!(user, record)
|
108
|
-
|
109
|
-
return true if policy.public_send(action)
|
110
|
-
|
111
|
-
Rails.logger.info "Pundit: not allowed to #{action} this #{record.inspect}"
|
112
|
-
raise Pundit::NotAuthorizedError, query: action, policy: policy, record: record
|
113
|
-
end
|
114
|
-
|
115
|
-
def pundit_scope!(scope, user, action = nil)
|
116
|
-
action = convert_action(action, :index?)
|
117
|
-
pundit_authorize!(scope, user, action)
|
118
|
-
|
119
|
-
Pundit.policy_scope!(user, scope)
|
120
|
-
end
|
121
|
-
|
122
|
-
private
|
123
|
-
|
124
|
-
def convert_action(action, default)
|
125
|
-
action = action.to_s
|
126
|
-
|
127
|
-
return default if action.blank?
|
128
|
-
return action if action.ends_with?('?')
|
129
|
-
|
130
|
-
action + '?'
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
```
|
135
|
-
|
136
|
-
## Development
|
137
|
-
|
138
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
139
|
-
|
140
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
141
|
-
|
142
|
-
## Contributing
|
143
|
-
|
144
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/light-service. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
145
|
-
|
146
|
-
|
147
|
-
## License
|
148
|
-
|
149
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
1
|
+
# Light Services
|
2
|
+
![CI](https://github.com/light-ruby/light-services/workflows/CI/badge.svg)
|
3
|
+
[![Codecov](https://codecov.io/gh/light-ruby/light-services/branch/master/graph/badge.svg)](https://codecov.io/gh/light-ruby/light-services)
|
150
4
|
|