rails_application_service 0.5.0 → 0.6.0

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: b7e3b78a33f41ea84a56ce29d482a739d1c4431122ec8eb766d76fd4d4598552
4
+ data.tar.gz: 5cf617de77f52dad4444d4cdfefbfd84b62e1bf2d54a3e0140dd64d890ab5661
5
5
  SHA512:
6
- metadata.gz: 6396cdf5260b37a651d9d09a06e9e37f8f4fb5a54d16f8de44ed055550910abfcbb369c3fdd97901e25c7b55154744715ed47721f9ab73d3534f5fa7c170e7ee
7
- data.tar.gz: 37118f9adfcc779cbd17f50af24505921a0098ce2c5a95e2361694eb497f0fc125fabe4869b8d7892bfa6246126b9043a0c82fcac04a788471a768c7597ddbb3
6
+ metadata.gz: 6116887b8a93ab25f5efcea6ab0e03c3f9cffd75aa7be4df4437956979db258b9d9ac671fa43323ebf26b2e78a5b3787c36ea888c41d07063d46e2c0d99e8948
7
+ data.tar.gz: cf929d8a4dad1d3f330a35b65cf1506aa67d0c0ab18c3113b9bab6a1451593c1862f74c321bf0a6fac15dd24fdee79073dfbb7f2b9400971c581a13743f7d561
data/CHANGELOG.md CHANGED
@@ -1,22 +1,16 @@
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
9
-
10
- Here we write upgrading notes for brands. It's a team effort to make them as
11
- straightforward as possible.
8
+ ## [0.6.0] - 2025-06-16
12
9
 
13
10
  ### 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
11
 
19
12
  ### Changed
13
+ - Enhanced the changelog
20
14
 
21
15
  ### Removed
22
16
 
@@ -27,10 +21,10 @@ straightforward as possible.
27
21
  ### Added
28
22
 
29
23
  ### Changed
30
- - Code documentation and Readme were enhanced
31
- - Test specs were refactored and simplified
32
- - Rubocop offenses were fixed
33
- - Dependencies were updated
24
+ - Improved code documentation and README
25
+ - Refactored and simplified test specs
26
+ - Fixed Rubocop offenses
27
+ - Updated dependencies
34
28
 
35
29
  ### Removed
36
30
 
@@ -39,17 +33,17 @@ straightforward as possible.
39
33
  ## [0.4.0] - 2025-06-16
40
34
 
41
35
  ### 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
36
+ - Added support for `ActiveModel::API` and `ActiveModel::Attributes`
37
+ - Enabled type casting through `ActiveModel::Attributes`
38
+ - Added validation via `ActiveModel::Validations`
45
39
 
46
40
  ### Changed
47
- - Service initialization now uses keyword arguments exclusively
41
+ - Service initialization now exclusively uses keyword arguments
48
42
  - Improved error messages and documentation
49
43
  - Enhanced example code in docstrings
50
44
 
51
45
  ### Removed
52
- - Support for positional arguments in the `call` method
46
+ - Removed support for positional arguments in the `call` method
53
47
 
54
48
  ### Breaking Changes
55
49
  - Services must now use keyword arguments instead of positional arguments
@@ -60,7 +54,7 @@ straightforward as possible.
60
54
  ### Added
61
55
 
62
56
  ### Changed
63
- - Source code and tests were refactored
57
+ - Refactored source code and tests
64
58
 
65
59
  ### Removed
66
60
 
@@ -71,7 +65,7 @@ straightforward as possible.
71
65
  ### Added
72
66
 
73
67
  ### Changed
74
- - Source code and tests were refactored
68
+ - Refactored source code and tests
75
69
 
76
70
  ### Removed
77
71
 
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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mário Marroquim