rails_application_service 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +8 -30
- data/lib/application_service/version.rb +1 -1
- data/lib/application_service.rb +7 -24
- metadata +7 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a6b7f0644b23fc57ff0d7219b7ae0040340365dba01fea27a93e5d675622200
|
|
4
|
+
data.tar.gz: 58743015a4952874518e175f2a7ecb1e0c88cfc0b3a160b5fd2925f6810c2c5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e33a5cebde38e7a49706f17e29aeee5b7e21f9edb67305debdd94c1e41b5f80a9c1f831aa80da97b0de52570c6a91c424507c47aa02208a8e070a11616b5a97e
|
|
7
|
+
data.tar.gz: 3abc11d67ab4929c77868e52f6d32e05f4092e16e106229bdd4a27a52f9df92c481c4199ba109301a17cd05a3840bc5e48a2fb56bdb247abbcfcce25694069b3
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4.0.3
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project are documented in this file.
|
|
|
5
5
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.6.2] - in progress
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Simplified docs
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
8
19
|
## [0.6.1] - 2025-06-18
|
|
9
20
|
|
|
10
21
|
### Added
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Rails Application Service
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This Ruby gem adds service classes (for example, use cases, features, or commands) to Ruby on Rails web applications.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -24,13 +24,11 @@ mkdir -p app/services
|
|
|
24
24
|
|
|
25
25
|
## Usage
|
|
26
26
|
|
|
27
|
-
The `ApplicationService::Base` class provides a standard interface for calling
|
|
27
|
+
The `ApplicationService::Base` class provides a standard interface for calling services. It leverages `ActiveModel` for initialization with keyword arguments and input validation.
|
|
28
28
|
|
|
29
29
|
### Basic service example
|
|
30
30
|
|
|
31
31
|
```ruby
|
|
32
|
-
require "application_service"
|
|
33
|
-
|
|
34
32
|
class MyService < ApplicationService::Base
|
|
35
33
|
def call
|
|
36
34
|
# Perform the service action
|
|
@@ -43,11 +41,8 @@ my_service = MyService.call # nil
|
|
|
43
41
|
### Example with attributes and validations
|
|
44
42
|
|
|
45
43
|
```ruby
|
|
46
|
-
require "application_service"
|
|
47
|
-
|
|
48
44
|
class Sum < ApplicationService::Base
|
|
49
|
-
|
|
50
|
-
attribute :number_b, :integer
|
|
45
|
+
attr_accessor :number_a, :number_b
|
|
51
46
|
|
|
52
47
|
validates :number_a, :number_b, presence: true, numericality: { greater_than: 0 }
|
|
53
48
|
|
|
@@ -59,36 +54,19 @@ end
|
|
|
59
54
|
sum = Sum.call(number_a: 1, number_b: 2) # => 3
|
|
60
55
|
```
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
This gem supports the following attribute types through `ActiveModel::Attributes` and custom types defined in `ActiveModel::Type`:
|
|
57
|
+
## Contributing
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
- `:date`
|
|
68
|
-
- `:datetime`
|
|
69
|
-
- `:decimal`
|
|
70
|
-
- `:float`
|
|
71
|
-
- `:integer`
|
|
72
|
-
- `:string`
|
|
73
|
-
- `:time`
|
|
59
|
+
Bug reports and pull requests are welcome on GitHub: [mariomarroquim/rails_application_service](https://github.com/mariomarroquim/rails_application_service). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to follow the [Code of Conduct](https://github.com/mariomarroquim/rails_application_service/blob/main/CODE_OF_CONDUCT.md).
|
|
74
60
|
|
|
75
61
|
## Development
|
|
76
62
|
|
|
77
|
-
After checking out the
|
|
63
|
+
After checking out the repository, run `bin/setup` to install dependencies. Then run `rake spec` to execute the test suite. You can also run `bin/console` to open an interactive prompt for experimentation.
|
|
78
64
|
|
|
79
|
-
To install this gem
|
|
80
|
-
|
|
81
|
-
## Contributing
|
|
82
|
-
|
|
83
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/mariomarroquim/rails_application_service. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mariomarroquim/rails_application_service/blob/main/CODE_OF_CONDUCT.md).
|
|
65
|
+
To install this gem on your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, then run `bundle exec rake release`. This command creates a git tag for the version, pushes the commits and tag, and publishes the `.gem` file to [RubyGems.org](https://rubygems.org).
|
|
84
66
|
|
|
85
67
|
## License
|
|
86
68
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## Code of Conduct
|
|
90
|
-
|
|
91
|
-
Everyone interacting in the ApplicationService project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/mariomarroquim/rails_application_service/blob/main/CODE_OF_CONDUCT.md).
|
|
69
|
+
This gem is available as open source under the terms of the [MIT License](https://github.com/mariomarroquim/rails_application_service/blob/main/LICENSE.txt).
|
|
92
70
|
|
|
93
71
|
## Support
|
|
94
72
|
|
data/lib/application_service.rb
CHANGED
|
@@ -8,16 +8,13 @@ require "active_model"
|
|
|
8
8
|
# perform a single action or a series of related actions.
|
|
9
9
|
module ApplicationService
|
|
10
10
|
# The Base class within the ApplicationService module provides a standard
|
|
11
|
-
# interface for calling service objects
|
|
12
|
-
#
|
|
13
|
-
# ActiveModel::Attributes for type casting, and ActiveModel::Validations for
|
|
14
|
-
# input validation.
|
|
11
|
+
# interface for calling service objects. It leverages ActiveModel for
|
|
12
|
+
# initialization with keyword arguments and input validation.
|
|
15
13
|
#
|
|
16
14
|
# Example usage:
|
|
17
15
|
#
|
|
18
16
|
# class Sum < ApplicationService::Base
|
|
19
|
-
#
|
|
20
|
-
# attribute :number_b, :integer
|
|
17
|
+
# attr_accessor :number_a, :number_b
|
|
21
18
|
#
|
|
22
19
|
# validates :number_a, :number_b, presence: true, numericality: { greater_than: 0 }
|
|
23
20
|
#
|
|
@@ -27,22 +24,8 @@ module ApplicationService
|
|
|
27
24
|
# end
|
|
28
25
|
#
|
|
29
26
|
# sum = Sum.call(number_a: 1, number_b: 2) # => 3
|
|
30
|
-
#
|
|
31
|
-
# This gem supports the following attribute types through ActiveModel::Attributes and
|
|
32
|
-
# other custom types defined in ActiveModel::Type:
|
|
33
|
-
#
|
|
34
|
-
# - :boolean
|
|
35
|
-
# - :date
|
|
36
|
-
# - :datetime
|
|
37
|
-
# - :decimal
|
|
38
|
-
# - :float
|
|
39
|
-
# - :integer
|
|
40
|
-
# - :string
|
|
41
|
-
# - :time
|
|
42
27
|
class Base
|
|
43
|
-
include ::ActiveModel::
|
|
44
|
-
include ::ActiveModel::Attributes
|
|
45
|
-
include ::ActiveModel::Validations
|
|
28
|
+
include ::ActiveModel::Model
|
|
46
29
|
|
|
47
30
|
# Initializes a new instance of the service object.
|
|
48
31
|
#
|
|
@@ -51,9 +34,9 @@ module ApplicationService
|
|
|
51
34
|
def initialize(**kwargs)
|
|
52
35
|
super
|
|
53
36
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
37
|
+
return unless instance_of?(Base)
|
|
38
|
+
|
|
39
|
+
raise ::NotImplementedError, "#{self.class.name} is an abstract class and cannot be instantiated directly"
|
|
57
40
|
end
|
|
58
41
|
|
|
59
42
|
# Instantiates a new service object and invokes its `call` method.
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_application_service
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mário Marroquim
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activemodel
|
|
@@ -23,7 +23,8 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '4.2'
|
|
26
|
-
description: This Ruby gem adds service
|
|
26
|
+
description: This Ruby gem adds service classes (e.g., use cases, features, or commands)
|
|
27
|
+
to Rails apps.
|
|
27
28
|
email:
|
|
28
29
|
- mariomarroquim@gmail.com
|
|
29
30
|
executables: []
|
|
@@ -47,7 +48,7 @@ licenses:
|
|
|
47
48
|
metadata:
|
|
48
49
|
homepage_uri: https://github.com/mariomarroquim/rails_application_service
|
|
49
50
|
changelog_uri: https://github.com/mariomarroquim/rails_application_service/CHANGELOG.md
|
|
50
|
-
rubygems_mfa_required: '
|
|
51
|
+
rubygems_mfa_required: 'true'
|
|
51
52
|
rdoc_options: []
|
|
52
53
|
require_paths:
|
|
53
54
|
- lib
|
|
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
62
63
|
- !ruby/object:Gem::Version
|
|
63
64
|
version: '0'
|
|
64
65
|
requirements: []
|
|
65
|
-
rubygems_version:
|
|
66
|
+
rubygems_version: 4.0.11
|
|
66
67
|
specification_version: 4
|
|
67
|
-
summary:
|
|
68
|
+
summary: Add service classes to Ruby on Rails web applications.
|
|
68
69
|
test_files: []
|