simple_ruby_service 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb4a3799e6b103c84e39eb31420d97e98205847c21da94846dca68f99375243d
4
- data.tar.gz: 00bd40999f571f0dddc67ac5437320628b2953a332ca87e3769c0b3bc46f14a3
3
+ metadata.gz: 93055c8359bf7677e53e99e5cae18f128e17f643770b51e207cdfd4892bf1ac2
4
+ data.tar.gz: 916d16d46e8c43ca5815e40b940df3d768e9d22fec56990fa29fb4c0610235a7
5
5
  SHA512:
6
- metadata.gz: b0331afb163c7f276e22b8ca2d7f536ec1850a462afa0f347ed5bcdf5af8aed19574ade60704f9eed49085a10b94376deb8298913baccbd8f7b809627e599f1c
7
- data.tar.gz: bc68c8a83661057d86a71b7d932f39c5ad46078a5cd1d5bfa1a543ea5995551a789691435045af7653676b86a7c010a032cdbb9482c4ebe95e2b5f838586eea2
6
+ metadata.gz: d68822b1a43f2a664c9e4b6f48a7b0a81de97686d346147e5b1d9bc6163e69d3df83a199908a82da6f2f694b704821aab54c019e35f35f3bfefed47c71499f42
7
+ data.tar.gz: cc1b27bbb4d6fd18dfb161d504787a4828a27a0babe4550f0864f1f9f9d740749a0e7983792b8e92d9f030ad7b1afa23be0220ee239939e4cf7cda3b11bb7d96
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.5 (22-Dec-21)
4
+
5
+ * Added setting to control automatically setting self.value with result of service methods
6
+
3
7
  ## 1.0.4 (02-Jul-21)
4
8
 
5
9
  * Polished README (again)
@@ -6,10 +6,13 @@ module SimpleRubyService
6
6
  extend ActiveSupport::Concern
7
7
  include ActiveModel::AttributeAssignment
8
8
  include ActiveModel::Validations
9
- include ActiveModel::Validations::Callbacks
9
+ include ActiveModel::Validations::Callbacks
10
10
 
11
11
  included do
12
12
  attr_accessor :value
13
+
14
+ class_attribute :set_value_when_service_methods_return
15
+ self.set_value_when_service_methods_return = true
13
16
  end
14
17
 
15
18
  class_methods do
@@ -33,7 +36,7 @@ module SimpleRubyService
33
36
  # Class level DSL that wraps the methods defined in inherited classes.
34
37
  def service_methods(&blk)
35
38
  Module.new.tap do |m| # Using anonymous modules so that super can be used to extend service methods
36
- m.module_eval &blk
39
+ m.module_eval(&blk)
37
40
  include m
38
41
 
39
42
  m.instance_methods.each do |service_method|
@@ -42,7 +45,8 @@ module SimpleRubyService
42
45
  # Returns self (for chainability).
43
46
  # Evaluates validity prior to executing the block provided.
44
47
  define_method service_method do |*args, **kwargs, &callback|
45
- perform(service_method, *args, **kwargs, &callback) if valid?
48
+ result = perform(service_method, *args, **kwargs, &callback) if valid?
49
+ self.value = result if set_value_when_service_methods_return
46
50
 
47
51
  self
48
52
  end
@@ -131,5 +135,3 @@ module SimpleRubyService
131
135
  end
132
136
  end
133
137
  end
134
-
135
-
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleRubyService
4
- VERSION = '1.0.5'
4
+ VERSION = '1.0.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_ruby_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Crouch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-25 00:00:00.000000000 Z
11
+ date: 2021-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel