Skip to content

Commit 4629780

Browse files
author
Mário Marroquim
committed
Simplify docs
1 parent 500ff22 commit 4629780

File tree

5 files changed

+18
-35
lines changed

5 files changed

+18
-35
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project are documented in this file.
55
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.6.2] - in progress
9+
10+
### Added
11+
12+
### Changed
13+
- Simplified docs
14+
15+
### Removed
16+
17+
### Breaking Changes
18+
819
## [0.6.1] - 2025-06-18
920

1021
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mkdir -p app/services
2424

2525
## Usage
2626

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+
The `ApplicationService::Base` class provides a standard interface for calling service objects. It leverages `ActiveModel` for initialization with keyword arguments and input validation.
2828

2929
### Basic service example
3030

lib/application_service.rb

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@
88
# perform a single action or a series of related actions.
99
module ApplicationService
1010
# The Base class within the ApplicationService module provides a standard
11-
# interface for calling service objects with robust type handling and validations.
12-
# It leverages ActiveModel::API for initialization with keyword arguments,
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.
1513
#
1614
# Example usage:
1715
#
1816
# class Sum < ApplicationService::Base
19-
# attribute :number_a, :integer
20-
# attribute :number_b, :integer
17+
# attr_accessor :number_a, :number_b
2118
#
2219
# validates :number_a, :number_b, presence: true, numericality: { greater_than: 0 }
2320
#
@@ -27,22 +24,8 @@ module ApplicationService
2724
# end
2825
#
2926
# sum = Sum.call(number_a: 1, number_b: 2) # => 3
30-
#
31-
# This gem supports the following attribute types through ActiveModel::Attributes and
32-
# custom types defined in ActiveModel::Type:
33-
#
34-
# - :boolean
35-
# - :date
36-
# - :datetime
37-
# - :decimal
38-
# - :float
39-
# - :integer
40-
# - :string
41-
# - :time
4227
class Base
43-
include ::ActiveModel::API
44-
include ::ActiveModel::Attributes
45-
include ::ActiveModel::Validations
28+
include ::ActiveModel::Model
4629

4730
# Initializes a new instance of the service object.
4831
#

lib/application_service/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ApplicationService
4-
VERSION = "0.6.1"
4+
VERSION = "0.6.2"
55
end

spec/sum_service_spec.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# frozen_string_literal: true
22

33
class SumService < ApplicationService::Base
4-
attribute :number_a, :integer
5-
attribute :number_b, :integer
4+
attr_accessor :number_a, :number_b
65

76
validates :number_a, :number_b, presence: true, numericality: { greater_than: 0 }
87

@@ -17,16 +16,6 @@ def call
1716
expect(sum).to eq(3)
1817
end
1918

20-
it "converts string numbers to integers" do
21-
sum = SumService.call(number_a: 1, number_b: "2")
22-
expect(sum).to eq(3)
23-
end
24-
25-
it "handles type conversion automatically" do
26-
sum = SumService.call(number_a: 1.5, number_b: "2.8")
27-
expect(sum).to eq(3)
28-
end
29-
3019
it "fails if no number is given" do
3120
sum = SumService.call(number_a: 1, number_b: nil)
3221
expect(sum).to be_falsey

0 commit comments

Comments
 (0)