rails_application_service 0.6.1 → 0.6.2
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/CHANGELOG.md +11 -0
- data/README.md +1 -1
- data/lib/application_service/version.rb +1 -1
- data/lib/application_service.rb +7 -24
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cc940286dc1211b1da1d8a01b48cff5ea2eb27c6680421870a05e6be229717b
|
4
|
+
data.tar.gz: f30bebb401ab83cc2db9c0489ece9e14a3dfb3d951179bbddb6d2f6838a01831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 296081b4f58ce03e5a89865da7e842a7b53be4c231ffbc4c931adf04fbf2e8d1e9b80a7f986f82c207597c2e6ff11a77aa6bfef1ddda2a69a1ad3373eab4b4c9
|
7
|
+
data.tar.gz: 6e2e0b4f148f50d9f5d097b306135d35f92b122abb20a160ef6079411f972d553bc0ec64fa57b8f9413e08ed0264f06713022747d1b800e1de9d1bea8a65d0c2
|
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/README.md
CHANGED
@@ -24,7 +24,7 @@ mkdir -p app/services
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
The `ApplicationService::Base` class provides a standard interface for calling service objects
|
27
|
+
The `ApplicationService::Base` class provides a standard interface for calling service objects. It leverages `ActiveModel` for initialization with keyword arguments and input validation.
|
28
28
|
|
29
29
|
### Basic service example
|
30
30
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mário Marroquim
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-08-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activemodel
|
@@ -47,7 +47,7 @@ licenses:
|
|
47
47
|
metadata:
|
48
48
|
homepage_uri: https://github.com/mariomarroquim/rails_application_service
|
49
49
|
changelog_uri: https://github.com/mariomarroquim/rails_application_service/CHANGELOG.md
|
50
|
-
rubygems_mfa_required: '
|
50
|
+
rubygems_mfa_required: 'true'
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|