rails_application_service 0.5.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce7c95dcdb2c3e8a3155219906c39a736ec5a5cb820e819d9f82291f09465fd
4
- data.tar.gz: 4a6f8d3dbd8af987d39922c8b9fcd3d55363c8037576349ec35c909ed56d7b87
3
+ metadata.gz: e47161deb51bec3466f37eb936845b0464f67d803962ebc65b5a88eb2b0d0770
4
+ data.tar.gz: 5e42179ec517d0c2ef2779bc46b8fe9c7c000f8fe595466edee79186074ca9d5
5
5
  SHA512:
6
- metadata.gz: 6396cdf5260b37a651d9d09a06e9e37f8f4fb5a54d16f8de44ed055550910abfcbb369c3fdd97901e25c7b55154744715ed47721f9ab73d3534f5fa7c170e7ee
7
- data.tar.gz: 37118f9adfcc779cbd17f50af24505921a0098ce2c5a95e2361694eb497f0fc125fabe4869b8d7892bfa6246126b9043a0c82fcac04a788471a768c7597ddbb3
6
+ metadata.gz: e45cf7ad68739ec61369f2c7aca8e8fbe9845f6fede5c663939eaf8dd68aba0c22c1a8cabd65423915a0976252e2269326f2ed8c9b0d391d5c8ddfc739bcc507
7
+ data.tar.gz: afe771aeb70c7b7153ed2bb7d6872a9f4ce814bf3485d6dd6077d269d31717f4b2a7461311abada17538451f50376a8c155ef02ee2305044315d1f73856e6f88
data/CHANGELOG.md CHANGED
@@ -1,55 +1,60 @@
1
- # Change Log
1
+ # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ All notable changes to this project are documented in this file.
4
4
 
5
- The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
- and this project adheres to [Semantic Versioning](http://semver.org/).
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased] - yyyy-mm-dd
8
+ ## [0.6.1] - 2025-06-18
9
9
 
10
- Here we write upgrading notes for brands. It's a team effort to make them as
11
- straightforward as possible.
10
+ ### Added
11
+
12
+ ### Changed
13
+ - Enhanced the changelog
14
+
15
+ ### Removed
16
+
17
+ ### Breaking Changes
18
+
19
+ ## [0.6.0] - 2025-06-18
12
20
 
13
21
  ### Added
14
- - [PROJECTNAME-XXXX](http://tickets.projectname.com/browse/PROJECTNAME-XXXX)
15
- MINOR Ticket title goes here.
16
- - [PROJECTNAME-YYYY](http://tickets.projectname.com/browse/PROJECTNAME-YYYY)
17
- PATCH Ticket title goes here.
18
22
 
19
23
  ### Changed
24
+ - Enhanced the changelog
20
25
 
21
26
  ### Removed
22
27
 
23
28
  ### Breaking Changes
24
29
 
25
- ## [0.5.0] - 2025-06-16
30
+ ## [0.5.0] - 2025-06-18
26
31
 
27
32
  ### Added
28
33
 
29
34
  ### Changed
30
- - Code documentation and Readme were enhanced
31
- - Test specs were refactored and simplified
32
- - Rubocop offenses were fixed
33
- - Dependencies were updated
35
+ - Improved code documentation and README
36
+ - Refactored and simplified test specs
37
+ - Fixed Rubocop offenses
38
+ - Updated dependencies
34
39
 
35
40
  ### Removed
36
41
 
37
42
  ### Breaking Changes
38
43
 
39
- ## [0.4.0] - 2025-06-16
44
+ ## [0.4.0] - 2025-06-05
40
45
 
41
46
  ### Added
42
- - Support for `ActiveModel::API` and `ActiveModel::Attributes` was added
43
- - Type casting through `ActiveModel::Attributes` was added
44
- - Validation through `ActiveModel::Validations` was added
47
+ - Added support for `ActiveModel::API` and `ActiveModel::Attributes`
48
+ - Enabled type casting through `ActiveModel::Attributes`
49
+ - Added validation via `ActiveModel::Validations`
45
50
 
46
51
  ### Changed
47
- - Service initialization now uses keyword arguments exclusively
52
+ - Service initialization now exclusively uses keyword arguments
48
53
  - Improved error messages and documentation
49
54
  - Enhanced example code in docstrings
50
55
 
51
56
  ### Removed
52
- - Support for positional arguments in the `call` method
57
+ - Removed support for positional arguments in the `call` method
53
58
 
54
59
  ### Breaking Changes
55
60
  - Services must now use keyword arguments instead of positional arguments
@@ -60,7 +65,7 @@ straightforward as possible.
60
65
  ### Added
61
66
 
62
67
  ### Changed
63
- - Source code and tests were refactored
68
+ - Refactored source code and tests
64
69
 
65
70
  ### Removed
66
71
 
@@ -71,7 +76,7 @@ straightforward as possible.
71
76
  ### Added
72
77
 
73
78
  ### Changed
74
- - Source code and tests were refactored
79
+ - Refactored source code and tests
75
80
 
76
81
  ### Removed
77
82
 
data/README.md CHANGED
@@ -1,22 +1,23 @@
1
1
  # Rails Application Service
2
2
 
3
- Service objects for Rails - the Rails way. This Ruby gem adds service objects to Rails applications.
3
+ Service objects for Rails, the Rails way. This Ruby gem adds service objects to your Rails applications.
4
4
 
5
5
  ## Installation
6
6
 
7
- **1 - Add the gem to the Rails application's Gemfile by entering:**
7
+ **1 - Add the gem to your Rails application's Gemfile:**
8
8
 
9
9
  ```bash
10
10
  bundle add rails_application_service
11
11
  ```
12
12
 
13
- **2 - Install the gem into the Rails application's directory by running:**
13
+ **2 - Install the gem by running:**
14
14
 
15
15
  ```bash
16
16
  bundle install
17
17
  ```
18
18
 
19
- **3 - Create an `app/services` subdirectory in the Rails application's directory by running:**
19
+ **3 - Create an `app/services` directory in your Rails application:**
20
+
20
21
  ```bash
21
22
  mkdir -p app/services
22
23
  ```
@@ -25,7 +26,8 @@ mkdir -p app/services
25
26
 
26
27
  The `ApplicationService::Base` class provides a standard interface for calling service objects with robust type handling and validations. It leverages `ActiveModel::API` for initialization with keyword arguments, `ActiveModel::Attributes` for type casting, and `ActiveModel::Validations` for input validation.
27
28
 
28
- ### Example of a basic service:
29
+ ### Basic service example
30
+
29
31
  ```ruby
30
32
  require "application_service"
31
33
 
@@ -38,7 +40,8 @@ end
38
40
  my_service = MyService.call # nil
39
41
  ```
40
42
 
41
- ### Example of a service:
43
+ ### Example with attributes and validations
44
+
42
45
  ```ruby
43
46
  require "application_service"
44
47
 
@@ -56,9 +59,9 @@ end
56
59
  sum = Sum.call(number_a: 1, number_b: 2) # => 3
57
60
  ```
58
61
 
59
- ### Available attribute types
62
+ ### Supported attribute types
60
63
 
61
- This gem supports the following attribute types through `ActiveModel::Attributes` and other custom types defined in `ActiveModel::Type`:
64
+ This gem supports the following attribute types through `ActiveModel::Attributes` and custom types defined in `ActiveModel::Type`:
62
65
 
63
66
  - `:boolean`
64
67
  - `:date`
@@ -71,9 +74,9 @@ This gem supports the following attribute types through `ActiveModel::Attributes
71
74
 
72
75
  ## Development
73
76
 
74
- 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.
77
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to execute the tests. You can also run `bin/console` for an interactive prompt to experiment.
75
78
 
76
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
79
+ 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`, then run `bundle exec rake release`. This will create a git tag for the version, push git commits and the tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
80
 
78
81
  ## Contributing
79
82
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApplicationService
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.1"
5
5
  end
@@ -46,24 +46,23 @@ module ApplicationService
46
46
 
47
47
  # Initializes a new instance of the service object.
48
48
  #
49
- # @param kwargs [Hash] the attributes to be passed to the service object
50
- # @raise [NotImplementedError] if an attempt is made to instantiate the Base class directly
49
+ # @param kwargs [Hash] The attributes to be passed to the service object.
50
+ # @raise [NotImplementedError] if an attempt is made to instantiate the Base class directly.
51
51
  def initialize(**kwargs)
52
52
  super
53
53
 
54
- return unless instance_of?(Base)
55
-
56
- raise ::NotImplementedError, "#{self.class.name} is an abstract class and cannot be instantiated directly"
54
+ if instance_of?(Base)
55
+ raise ::NotImplementedError, "#{self.class.name} is an abstract class and cannot be instantiated directly"
56
+ end
57
57
  end
58
58
 
59
- # Initializes a new instance of the service object and invokes its `call` method.
59
+ # Instantiates a new service object and invokes its `call` method.
60
60
  #
61
- # @param kwargs [Hash] the attributes to be passed to the service object
62
- # @return [Object] the result of the service object's call method
63
- # @return [false] if the service object is invalid
61
+ # @param kwargs [Hash] The attributes to be passed to the service object.
62
+ # @return [Object] The result of the service object's call method.
63
+ # @return [false] If the service object is invalid.
64
64
  def self.call(**kwargs)
65
65
  service = new(**kwargs)
66
-
67
66
  return false unless service.valid?
68
67
 
69
68
  service.call
@@ -71,7 +70,7 @@ module ApplicationService
71
70
 
72
71
  # Encapsulates the implementation to be executed by the service object.
73
72
  #
74
- # @raise [NotImplementedError] if the method is not implemented in a child class
73
+ # @raise [NotImplementedError] if the method is not implemented in a child class.
75
74
  def call
76
75
  raise ::NotImplementedError, "The `call` method must be implemented in #{self.class.name}"
77
76
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_application_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mário Marroquim