aws-lex-conversation 1.0.0 → 1.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 113a515e1c05389f5ab8d57fae23a54fc6cc212645d2bea1e091c5f750aabe08
|
4
|
+
data.tar.gz: b9233099ad5faae9ce4c530565be798703d5bfedccd981ab6835a8b6c01d5f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b712aef8787b4b0754b420027abddcee9ea51fe030c590c0caea229629099542d44979d1b8bf6b5a1e29a5bbf37c6ec10c33ac9493fbffbeeb6b84deb9daaaf3
|
7
|
+
data.tar.gz: 0cf7de36b758c798068ac23b4d1e73b07252b9ed39ed36bebdd648d0aa060088bfd5c77ea21fed00c8338ca9a434c540f0c5fd08f695011705672c24c7bfb926
|
@@ -19,7 +19,8 @@ module Aws
|
|
19
19
|
|
20
20
|
module InstanceMethods
|
21
21
|
def assign_attributes!(opts = {})
|
22
|
-
self.class.attributes
|
22
|
+
attributes = self.class.attributes | self.class.virtual_attributes
|
23
|
+
attributes.each do |attribute|
|
23
24
|
instance_variable_set("@#{attribute}", opts[attribute])
|
24
25
|
end
|
25
26
|
end
|
@@ -60,6 +61,17 @@ module Aws
|
|
60
61
|
->(v) { v.transform_keys(&:to_sym) }
|
61
62
|
end
|
62
63
|
|
64
|
+
def computed_property(attribute, callable)
|
65
|
+
mapping[attribute] = attribute
|
66
|
+
attr_writer(attribute)
|
67
|
+
|
68
|
+
# dynamically memoize the result
|
69
|
+
define_method(attribute) do
|
70
|
+
instance_variable_get("@#{attribute}") ||
|
71
|
+
instance_variable_set("@#{attribute}", callable.call(self))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
63
75
|
def required(attribute, opts = {})
|
64
76
|
property(attribute, opts.merge(allow_nil: false))
|
65
77
|
end
|
@@ -76,7 +88,12 @@ module Aws
|
|
76
88
|
|
77
89
|
attr_accessor(attribute)
|
78
90
|
|
79
|
-
|
91
|
+
if opts.fetch(:virtual) { false }
|
92
|
+
virtual_attributes << attribute
|
93
|
+
else
|
94
|
+
mapping[attribute] = from
|
95
|
+
end
|
96
|
+
|
80
97
|
translate(attribute => params)
|
81
98
|
end
|
82
99
|
|
@@ -84,6 +101,10 @@ module Aws
|
|
84
101
|
@attributes ||= mapping.keys
|
85
102
|
end
|
86
103
|
|
104
|
+
def virtual_attributes
|
105
|
+
@virtual_attributes ||= []
|
106
|
+
end
|
107
|
+
|
87
108
|
def mapping
|
88
109
|
@mapping ||= {}
|
89
110
|
end
|
@@ -8,22 +8,23 @@ module Aws
|
|
8
8
|
include Base
|
9
9
|
|
10
10
|
required :name
|
11
|
-
required :slots
|
11
|
+
required :raw_slots, from: :slots, virtual: true
|
12
12
|
required :slot_details
|
13
13
|
required :confirmation_status
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
15
|
+
computed_property :slots, ->(instance) do
|
16
|
+
instance.raw_slots.each_with_object({}) do |(key, value), hash|
|
17
|
+
hash[key.to_sym] = Slot.shrink_wrap(
|
18
|
+
name: key,
|
19
|
+
value: value,
|
20
|
+
# pass a reference to the parent down to the slot so that each slot
|
21
|
+
# instance can view a broader scope such as slot_details/resolutions
|
22
|
+
current_intent: instance
|
23
|
+
)
|
25
24
|
end
|
25
|
+
end
|
26
26
|
|
27
|
+
class << self
|
27
28
|
def slot_details!
|
28
29
|
->(v) do
|
29
30
|
v.each_with_object({}) do |(key, value), hash|
|
@@ -34,7 +35,6 @@ module Aws
|
|
34
35
|
end
|
35
36
|
|
36
37
|
coerce(
|
37
|
-
slots: slots!,
|
38
38
|
slot_details: slot_details!,
|
39
39
|
confirmation_status: ConfirmationStatus
|
40
40
|
)
|
@@ -7,6 +7,7 @@ module Aws
|
|
7
7
|
class Slot
|
8
8
|
include Base
|
9
9
|
|
10
|
+
required :current_intent, from: :current_intent, virtual: true
|
10
11
|
required :name
|
11
12
|
required :value
|
12
13
|
|
@@ -17,6 +18,28 @@ module Aws
|
|
17
18
|
def filled?
|
18
19
|
value.to_s != ''
|
19
20
|
end
|
21
|
+
|
22
|
+
def resolve!(index: 0)
|
23
|
+
self.value = resolved(index: index)
|
24
|
+
end
|
25
|
+
|
26
|
+
def resolved(index: 0)
|
27
|
+
details.resolutions.fetch(index) { SlotResolution.new(value: value) }.value
|
28
|
+
end
|
29
|
+
|
30
|
+
def original_value
|
31
|
+
details.original_value
|
32
|
+
end
|
33
|
+
|
34
|
+
def resolvable?
|
35
|
+
details.resolutions.any?
|
36
|
+
end
|
37
|
+
|
38
|
+
def details
|
39
|
+
@details ||= current_intent.slot_details.fetch(name.to_sym) do
|
40
|
+
SlotDetail.new(name: name, resolutions: [], original_value: value)
|
41
|
+
end
|
42
|
+
end
|
20
43
|
end
|
21
44
|
end
|
22
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-lex-conversation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Doyle
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: exe
|
14
14
|
cert_chain: []
|
15
|
-
date: 2020-06-
|
15
|
+
date: 2020-06-29 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: shrink_wrap
|