nueca_rails_interfaces 1.0.0 → 1.1.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: 375e0a33491c00461a59c058bc16531aa7297fb5974420baecc7d5bdf095984e
4
- data.tar.gz: 70fdf20fd30f3ac098c871bcb41470f5705e6b4a616d753ee6c362f7d8271589
3
+ metadata.gz: 42dd2f02e795aef50698e9a70249e3e0105c8a8e53a9208f1e75df110401a9ec
4
+ data.tar.gz: 10239f791667be7b7787ea03536c8d19f202ad0dae67eff292ba5688d3a1fd13
5
5
  SHA512:
6
- metadata.gz: 8bf069562ba00aaeba977893057fbfad0e6c5e5f4ef8ed1d4208e343e90174824eead398f7ba7ae952597a5c5ce0c8c7a705bc6a087a60eded76d1715d372508
7
- data.tar.gz: 756f5471261a09504b020119056f884f89a264ea29ae6c38d4402eb24876b1eed8751e1b561d67998ae8814d4ba86110060703eb830b47de6f92b7f094b822d8
6
+ metadata.gz: e4ea8b27bd401d4a0dbfeb111f82529f8b12ce0a79d11c0bc43b413130715964ad1416f08a27d42008b370e05f178b452646100988a85717b7af3b128042ae6e
7
+ data.tar.gz: 1baca017fc4728ca09f4e855ac186ea55b17a5ea9f62f7382faa67d740614a34db61cb67cce6fc47f44a5f09784f5f3d5d80b787986c5a5d4c81407cad8411ea
data/.rubocop.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  plugins:
2
2
  - rubocop-rails
3
3
  - rubocop-rake
4
-
5
- require:
6
4
  - rubocop-rspec
7
5
 
8
6
  AllCops:
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- NRI = NuecaRailsInterfaces
4
-
5
3
  module NuecaRailsInterfaces
6
4
  # Utility module helper.
7
5
  module Util
@@ -7,12 +7,14 @@ module NuecaRailsInterfaces
7
7
  module ServiceInterface
8
8
  class << self
9
9
  def included(base)
10
+ raise NuecaRailsInterfaces::DeprecatedError
11
+
10
12
  # This is the main method of the service in a class context.
11
13
  # This is the method that should be called to perform the service statically.
12
14
  # Use this instead if the service instance is not needed.
13
15
  # Do not override this method. Instead, override the `action` method. Returns the data immediately.
14
16
  # @return [Object] Data of the service.
15
- base.define_singleton_method(:perform) do |*arguments|
17
+ base.define_singleton_method(:perform) do |*arguments| # rubocop:disable Lint/UnreachableCode
16
18
  instance = NuecaRailsInterfaces::Util.process_class_arguments(self, *arguments)
17
19
  instance.perform
18
20
  end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NuecaRailsInterfaces
4
+ module V3
5
+ # V3 Service Interface adds a way for developers to determine if it was ran successfully or not.
6
+ # When performing the service, it will immediately return the data.
7
+ # It will also assign the success? attribute of the class.
8
+ # The action method should return a boolean value.
9
+ # Warnings feature is now also removed.
10
+ module ServiceInterface
11
+ class << self
12
+ def included(base)
13
+ # This is the main method of the service in a class context.
14
+ # This is the method that should be called to perform the service statically.
15
+ # Use this instead if the service instance is not needed.
16
+ # Do not override this method. Instead, override the `action` method. Returns the data immediately.
17
+ # @return [Object] Data of the service.
18
+ base.define_singleton_method(:perform) do |*arguments|
19
+ instance = NuecaRailsInterfaces::Util.process_class_arguments(self, *arguments)
20
+ instance.perform
21
+ end
22
+ end
23
+ end
24
+
25
+ # This is the main method of the service. This is the method that should be called to perform the service.
26
+ # Do not override this method. Instead, override the `action` method. Returns the data immediately.
27
+ # @return [Object] Data of the service.
28
+ def perform
29
+ unless performed?
30
+ @success = action.present?
31
+ @performed = true
32
+ end
33
+
34
+ data
35
+ end
36
+
37
+ # Override this method and put the main logic of the service here.
38
+ # @raise [NotImplementedError] If the method is not overridden.
39
+ # @return [void]
40
+ def action
41
+ raise NotImplementedError, 'Requires implementation of action.'
42
+ end
43
+
44
+ # Override this method and put the resulting data of the service here.
45
+ # If blank, then return an empty hash manually.
46
+ # Reason being is for readability's sake in the services.
47
+ # @raise [NotImplementedError] If the method is not overridden.
48
+ # @return [Object] Data of the service.
49
+ def data
50
+ raise NotImplementedError, 'Requires implementation of data.'
51
+ end
52
+
53
+ # Checks if the service has been performed. Do not override.
54
+ # @return [Boolean] True or False
55
+ def performed?
56
+ performed
57
+ end
58
+
59
+ # Returns the service's status if it performed successfully or not.
60
+ # Nil return means that the service is still not performed.
61
+ # @return [Boolean, nil] True or False or nil
62
+ def success?
63
+ @success
64
+ end
65
+
66
+ private
67
+
68
+ # Status of the service. If the service has been performed, this should be true.
69
+ # Do not override this method.
70
+ # @return [Boolean] True or False
71
+ def performed
72
+ @performed ||= false
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NuecaRailsInterfaces
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nueca_rails_interfaces
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-06-23 00:00:00.000000000 Z
10
+ date: 2025-08-27 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -49,7 +49,6 @@ executables: []
49
49
  extensions: []
50
50
  extra_rdoc_files: []
51
51
  files:
52
- - ".byebug_history"
53
52
  - ".rspec"
54
53
  - ".rubocop.yml"
55
54
  - CODE_OF_CONDUCT.md
@@ -65,6 +64,7 @@ files:
65
64
  - lib/nueca_rails_interfaces/v1/service_interface.rb
66
65
  - lib/nueca_rails_interfaces/v2/form_interface.rb
67
66
  - lib/nueca_rails_interfaces/v2/service_interface.rb
67
+ - lib/nueca_rails_interfaces/v3/service_interface.rb
68
68
  - lib/nueca_rails_interfaces/version.rb
69
69
  - nueca_rails_interfaces.gemspec
70
70
  homepage: https://github.com/tieeeeen1994/nueca-rails-interfaces
data/.byebug_history DELETED
@@ -1,7 +0,0 @@
1
- exit
2
- defined?(Node)
3
- c
4
- exit
5
- defined?(Node)
6
- exit
7
- c