telephone 0.1.0 → 1.0.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 +4 -4
- data/lib/telephone/service.rb +30 -3
- data/lib/telephone/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b95df7745edfdcccffb9d141f444fb2b487b55d0cd20ae6e1dd86a51033f064a
|
4
|
+
data.tar.gz: 3d680e1fecccb620ab8823e0e46cba6b9fa506f1718b5486e38750ccf4ab86ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd79447632f18c1ac6237254589df28980098b1988172886b10c3a46e2e2ea6bf6122d81219653111a51dbfc75edefea2b79450905c099875bb48ab5e6fcdd1b
|
7
|
+
data.tar.gz: d40dd3b806a554920571c40841ccc539a1531eef7cde07800a171cfc9b5cbcf4a2f98c140fa702f22bbc1e3d2e68077c55cd21c45eafbf2af464dfdc9a2431cb
|
data/lib/telephone/service.rb
CHANGED
@@ -16,6 +16,18 @@ module Telephone
|
|
16
16
|
# Telephone::Service.call(foo: bar).result # "baz"
|
17
17
|
attr_accessor :result
|
18
18
|
|
19
|
+
##
|
20
|
+
# Primary responsibility of initialize is to instantiate the
|
21
|
+
# attributes of the service object with the expected values.
|
22
|
+
def initialize(attributes = {})
|
23
|
+
self.class.defaults.merge(attributes).each do |key, value|
|
24
|
+
send("#{key}=", value)
|
25
|
+
end
|
26
|
+
|
27
|
+
super
|
28
|
+
yield self if block_given?
|
29
|
+
end
|
30
|
+
|
19
31
|
##
|
20
32
|
# Determines whether or not the action of the service
|
21
33
|
# object was successful.
|
@@ -28,6 +40,11 @@ module Telephone
|
|
28
40
|
errors.empty?
|
29
41
|
end
|
30
42
|
|
43
|
+
def call
|
44
|
+
self.result = __call if valid?
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
31
48
|
class << self
|
32
49
|
##
|
33
50
|
# Defines a getter/setter for a service object argument. This also allows you
|
@@ -66,9 +83,19 @@ module Telephone
|
|
66
83
|
# @example
|
67
84
|
# Telephone::Service.call(foo: bar)
|
68
85
|
def call(**args)
|
69
|
-
|
70
|
-
|
71
|
-
|
86
|
+
new(args).call
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# When the subclass overwrites the #call method, reassign it to #__call.
|
91
|
+
# This allows us to still control what happens in the instance level of #call.
|
92
|
+
def method_added(method_name)
|
93
|
+
if method_name == :call
|
94
|
+
alias_method :__call, :call
|
95
|
+
send(:remove_method, :call)
|
96
|
+
else
|
97
|
+
super
|
98
|
+
end
|
72
99
|
end
|
73
100
|
end
|
74
101
|
end
|
data/lib/telephone/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telephone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Hargett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements:
|
58
58
|
- none
|
59
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.1.6
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Utility class for creating and calling service objects.
|