oci 2.3.2 → 2.3.3
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/README.md +6 -5
- data/lib/oci.rb +1 -0
- data/lib/oci/api_client.rb +2 -2
- data/lib/oci/auth/federation_client.rb +1 -0
- data/lib/oci/auth/signers/instance_principals_security_token_signer.rb +1 -1
- data/lib/oci/auth/signers/x509_federation_client_based_security_token_signer.rb +2 -1
- data/lib/oci/core/compute_client.rb +7 -5
- data/lib/oci/core/models/create_boot_volume_details.rb +17 -1
- data/lib/oci/core/models/egress_security_rule.rb +19 -5
- data/lib/oci/core/models/fast_connect_provider_service.rb +2 -2
- data/lib/oci/core/models/ingress_security_rule.rb +16 -7
- data/lib/oci/core/models/instance.rb +0 -2
- data/lib/oci/core/models/launch_instance_details.rb +0 -2
- data/lib/oci/core/models/route_rule.rb +19 -8
- data/lib/oci/core/models/virtual_circuit.rb +6 -1
- data/lib/oci/regions.rb +2 -1
- data/lib/oci/resource_search/models/free_text_search_details.rb +158 -0
- data/lib/oci/resource_search/models/queryable_field_description.rb +225 -0
- data/lib/oci/resource_search/models/resource_summary.rb +272 -0
- data/lib/oci/resource_search/models/resource_summary_collection.rb +146 -0
- data/lib/oci/resource_search/models/resource_type.rb +158 -0
- data/lib/oci/resource_search/models/search_context.rb +149 -0
- data/lib/oci/resource_search/models/search_details.rb +192 -0
- data/lib/oci/resource_search/models/structured_search_details.rb +158 -0
- data/lib/oci/resource_search/resource_search.rb +26 -0
- data/lib/oci/resource_search/resource_search_client.rb +279 -0
- data/lib/oci/resource_search/resource_search_client_composite_operations.rb +24 -0
- data/lib/oci/resource_search/util.rb +2 -0
- data/lib/oci/version.rb +1 -1
- metadata +14 -2
@@ -0,0 +1,146 @@
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
# rubocop:disable Lint/UnneededCopDisableDirective
|
6
|
+
module OCI
|
7
|
+
# Summary representation of resources that matched the search criteria.
|
8
|
+
class ResourceSearch::Models::ResourceSummaryCollection # rubocop:disable Metrics/LineLength
|
9
|
+
# A list of resources.
|
10
|
+
# @return [Array<OCI::ResourceSearch::Models::ResourceSummary>]
|
11
|
+
attr_accessor :items
|
12
|
+
|
13
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
14
|
+
def self.attribute_map
|
15
|
+
{
|
16
|
+
# rubocop:disable Style/SymbolLiteral
|
17
|
+
'items': :'items'
|
18
|
+
# rubocop:enable Style/SymbolLiteral
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attribute type mapping.
|
23
|
+
def self.swagger_types
|
24
|
+
{
|
25
|
+
# rubocop:disable Style/SymbolLiteral
|
26
|
+
'items': :'Array<OCI::ResourceSearch::Models::ResourceSummary>'
|
27
|
+
# rubocop:enable Style/SymbolLiteral
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
32
|
+
# rubocop:disable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
|
33
|
+
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
# @option attributes [Array<OCI::ResourceSearch::Models::ResourceSummary>] :items The value to assign to the {#items} property
|
38
|
+
def initialize(attributes = {})
|
39
|
+
return unless attributes.is_a?(Hash)
|
40
|
+
|
41
|
+
# convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
43
|
+
|
44
|
+
self.items = attributes[:'items'] if attributes[:'items']
|
45
|
+
end
|
46
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
47
|
+
# rubocop:enable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
|
48
|
+
|
49
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
|
50
|
+
|
51
|
+
|
52
|
+
# Checks equality by comparing each attribute.
|
53
|
+
# @param [Object] other the other object to be compared
|
54
|
+
def ==(other)
|
55
|
+
return true if equal?(other)
|
56
|
+
self.class == other.class &&
|
57
|
+
items == other.items
|
58
|
+
end
|
59
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
|
60
|
+
|
61
|
+
# @see the `==` method
|
62
|
+
# @param [Object] other the other object to be compared
|
63
|
+
def eql?(other)
|
64
|
+
self == other
|
65
|
+
end
|
66
|
+
|
67
|
+
# rubocop:disable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
|
68
|
+
|
69
|
+
|
70
|
+
# Calculates hash code according to all attributes.
|
71
|
+
# @return [Fixnum] Hash code
|
72
|
+
def hash
|
73
|
+
[items].hash
|
74
|
+
end
|
75
|
+
# rubocop:enable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
|
76
|
+
|
77
|
+
# rubocop:disable Metrics/AbcSize, Layout/EmptyLines
|
78
|
+
|
79
|
+
|
80
|
+
# Builds the object from hash
|
81
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
82
|
+
# @return [Object] Returns the model itself
|
83
|
+
def build_from_hash(attributes)
|
84
|
+
return nil unless attributes.is_a?(Hash)
|
85
|
+
self.class.swagger_types.each_pair do |key, type|
|
86
|
+
if type =~ /^Array<(.*)>/i
|
87
|
+
# check to ensure the input is an array given that the the attribute
|
88
|
+
# is documented as an array but the input is not
|
89
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
90
|
+
public_method("#{key}=").call(
|
91
|
+
attributes[self.class.attribute_map[key]]
|
92
|
+
.map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
|
93
|
+
)
|
94
|
+
end
|
95
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
+
public_method("#{key}=").call(
|
97
|
+
OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
|
98
|
+
)
|
99
|
+
end
|
100
|
+
# or else data not found in attributes(hash), not an issue as the data can be optional
|
101
|
+
end
|
102
|
+
|
103
|
+
self
|
104
|
+
end
|
105
|
+
# rubocop:enable Metrics/AbcSize, Layout/EmptyLines
|
106
|
+
|
107
|
+
# Returns the string representation of the object
|
108
|
+
# @return [String] String presentation of the object
|
109
|
+
def to_s
|
110
|
+
to_hash.to_s
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns the object in the form of hash
|
114
|
+
# @return [Hash] Returns the object in the form of hash
|
115
|
+
def to_hash
|
116
|
+
hash = {}
|
117
|
+
self.class.attribute_map.each_pair do |attr, param|
|
118
|
+
value = public_method(attr).call
|
119
|
+
next if value.nil? && !instance_variable_defined?("@#{attr}")
|
120
|
+
hash[param] = _to_hash(value)
|
121
|
+
end
|
122
|
+
hash
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
|
127
|
+
# Outputs non-array value in the form of hash
|
128
|
+
# For object, use to_hash. Otherwise, just return the value
|
129
|
+
# @param [Object] value Any valid value
|
130
|
+
# @return [Hash] Returns the value in the form of hash
|
131
|
+
def _to_hash(value)
|
132
|
+
if value.is_a?(Array)
|
133
|
+
value.compact.map { |v| _to_hash(v) }
|
134
|
+
elsif value.is_a?(Hash)
|
135
|
+
{}.tap do |hash|
|
136
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
137
|
+
end
|
138
|
+
elsif value.respond_to? :to_hash
|
139
|
+
value.to_hash
|
140
|
+
else
|
141
|
+
value
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
# rubocop:enable Lint/UnneededCopDisableDirective
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
# rubocop:disable Lint/UnneededCopDisableDirective
|
6
|
+
module OCI
|
7
|
+
# Defines a type of resource that you can find with a search or query.
|
8
|
+
class ResourceSearch::Models::ResourceType # rubocop:disable Metrics/LineLength
|
9
|
+
# **[Required]** The unique name of the resource type, which matches the value returned as part of the ResourceSummary object.
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
attr_accessor :name
|
13
|
+
|
14
|
+
# **[Required]** List of all the fields and their value type that are indexed for querying.
|
15
|
+
#
|
16
|
+
# @return [Array<OCI::ResourceSearch::Models::QueryableFieldDescription>]
|
17
|
+
attr_accessor :fields
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
# rubocop:disable Style/SymbolLiteral
|
23
|
+
'name': :'name',
|
24
|
+
'fields': :'fields'
|
25
|
+
# rubocop:enable Style/SymbolLiteral
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
# rubocop:disable Style/SymbolLiteral
|
33
|
+
'name': :'String',
|
34
|
+
'fields': :'Array<OCI::ResourceSearch::Models::QueryableFieldDescription>'
|
35
|
+
# rubocop:enable Style/SymbolLiteral
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
40
|
+
# rubocop:disable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
|
41
|
+
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
# @option attributes [String] :name The value to assign to the {#name} property
|
46
|
+
# @option attributes [Array<OCI::ResourceSearch::Models::QueryableFieldDescription>] :fields The value to assign to the {#fields} property
|
47
|
+
def initialize(attributes = {})
|
48
|
+
return unless attributes.is_a?(Hash)
|
49
|
+
|
50
|
+
# convert string to symbol for hash key
|
51
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
52
|
+
|
53
|
+
self.name = attributes[:'name'] if attributes[:'name']
|
54
|
+
|
55
|
+
self.fields = attributes[:'fields'] if attributes[:'fields']
|
56
|
+
end
|
57
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
58
|
+
# rubocop:enable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
|
59
|
+
|
60
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
|
61
|
+
|
62
|
+
|
63
|
+
# Checks equality by comparing each attribute.
|
64
|
+
# @param [Object] other the other object to be compared
|
65
|
+
def ==(other)
|
66
|
+
return true if equal?(other)
|
67
|
+
self.class == other.class &&
|
68
|
+
name == other.name &&
|
69
|
+
fields == other.fields
|
70
|
+
end
|
71
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
|
72
|
+
|
73
|
+
# @see the `==` method
|
74
|
+
# @param [Object] other the other object to be compared
|
75
|
+
def eql?(other)
|
76
|
+
self == other
|
77
|
+
end
|
78
|
+
|
79
|
+
# rubocop:disable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
|
80
|
+
|
81
|
+
|
82
|
+
# Calculates hash code according to all attributes.
|
83
|
+
# @return [Fixnum] Hash code
|
84
|
+
def hash
|
85
|
+
[name, fields].hash
|
86
|
+
end
|
87
|
+
# rubocop:enable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
|
88
|
+
|
89
|
+
# rubocop:disable Metrics/AbcSize, Layout/EmptyLines
|
90
|
+
|
91
|
+
|
92
|
+
# Builds the object from hash
|
93
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
94
|
+
# @return [Object] Returns the model itself
|
95
|
+
def build_from_hash(attributes)
|
96
|
+
return nil unless attributes.is_a?(Hash)
|
97
|
+
self.class.swagger_types.each_pair do |key, type|
|
98
|
+
if type =~ /^Array<(.*)>/i
|
99
|
+
# check to ensure the input is an array given that the the attribute
|
100
|
+
# is documented as an array but the input is not
|
101
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
102
|
+
public_method("#{key}=").call(
|
103
|
+
attributes[self.class.attribute_map[key]]
|
104
|
+
.map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
|
105
|
+
)
|
106
|
+
end
|
107
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
108
|
+
public_method("#{key}=").call(
|
109
|
+
OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
|
110
|
+
)
|
111
|
+
end
|
112
|
+
# or else data not found in attributes(hash), not an issue as the data can be optional
|
113
|
+
end
|
114
|
+
|
115
|
+
self
|
116
|
+
end
|
117
|
+
# rubocop:enable Metrics/AbcSize, Layout/EmptyLines
|
118
|
+
|
119
|
+
# Returns the string representation of the object
|
120
|
+
# @return [String] String presentation of the object
|
121
|
+
def to_s
|
122
|
+
to_hash.to_s
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns the object in the form of hash
|
126
|
+
# @return [Hash] Returns the object in the form of hash
|
127
|
+
def to_hash
|
128
|
+
hash = {}
|
129
|
+
self.class.attribute_map.each_pair do |attr, param|
|
130
|
+
value = public_method(attr).call
|
131
|
+
next if value.nil? && !instance_variable_defined?("@#{attr}")
|
132
|
+
hash[param] = _to_hash(value)
|
133
|
+
end
|
134
|
+
hash
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
# Outputs non-array value in the form of hash
|
140
|
+
# For object, use to_hash. Otherwise, just return the value
|
141
|
+
# @param [Object] value Any valid value
|
142
|
+
# @return [Hash] Returns the value in the form of hash
|
143
|
+
def _to_hash(value)
|
144
|
+
if value.is_a?(Array)
|
145
|
+
value.compact.map { |v| _to_hash(v) }
|
146
|
+
elsif value.is_a?(Hash)
|
147
|
+
{}.tap do |hash|
|
148
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
149
|
+
end
|
150
|
+
elsif value.respond_to? :to_hash
|
151
|
+
value.to_hash
|
152
|
+
else
|
153
|
+
value
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
# rubocop:enable Lint/UnneededCopDisableDirective
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
# rubocop:disable Lint/UnneededCopDisableDirective
|
6
|
+
module OCI
|
7
|
+
# Contains search context, such as highlighting, for found resources.
|
8
|
+
class ResourceSearch::Models::SearchContext # rubocop:disable Metrics/LineLength
|
9
|
+
# Describes what in each field matched the search criteria by showing highlighted values, but only for free text searches or for structured
|
10
|
+
# queries that use a MATCHING clause. The list of strings represents fragments of values that matched the query conditions. Highlighted
|
11
|
+
# values are wrapped with <hl>..</hl> tags. All values are HTML-encoded (except <hl> tags).
|
12
|
+
#
|
13
|
+
# @return [Hash<String, Array<String>>]
|
14
|
+
attr_accessor :highlights
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
# rubocop:disable Style/SymbolLiteral
|
20
|
+
'highlights': :'highlights'
|
21
|
+
# rubocop:enable Style/SymbolLiteral
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attribute type mapping.
|
26
|
+
def self.swagger_types
|
27
|
+
{
|
28
|
+
# rubocop:disable Style/SymbolLiteral
|
29
|
+
'highlights': :'Hash<String, Array<String>>'
|
30
|
+
# rubocop:enable Style/SymbolLiteral
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
35
|
+
# rubocop:disable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
|
36
|
+
|
37
|
+
|
38
|
+
# Initializes the object
|
39
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
40
|
+
# @option attributes [Hash<String, Array<String>>] :highlights The value to assign to the {#highlights} property
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
46
|
+
|
47
|
+
self.highlights = attributes[:'highlights'] if attributes[:'highlights']
|
48
|
+
end
|
49
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
50
|
+
# rubocop:enable Metrics/LineLength, Metrics/MethodLength, Layout/EmptyLines, Style/SymbolLiteral
|
51
|
+
|
52
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
|
53
|
+
|
54
|
+
|
55
|
+
# Checks equality by comparing each attribute.
|
56
|
+
# @param [Object] other the other object to be compared
|
57
|
+
def ==(other)
|
58
|
+
return true if equal?(other)
|
59
|
+
self.class == other.class &&
|
60
|
+
highlights == other.highlights
|
61
|
+
end
|
62
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Layout/EmptyLines
|
63
|
+
|
64
|
+
# @see the `==` method
|
65
|
+
# @param [Object] other the other object to be compared
|
66
|
+
def eql?(other)
|
67
|
+
self == other
|
68
|
+
end
|
69
|
+
|
70
|
+
# rubocop:disable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
|
71
|
+
|
72
|
+
|
73
|
+
# Calculates hash code according to all attributes.
|
74
|
+
# @return [Fixnum] Hash code
|
75
|
+
def hash
|
76
|
+
[highlights].hash
|
77
|
+
end
|
78
|
+
# rubocop:enable Metrics/AbcSize, Metrics/LineLength, Layout/EmptyLines
|
79
|
+
|
80
|
+
# rubocop:disable Metrics/AbcSize, Layout/EmptyLines
|
81
|
+
|
82
|
+
|
83
|
+
# Builds the object from hash
|
84
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
+
# @return [Object] Returns the model itself
|
86
|
+
def build_from_hash(attributes)
|
87
|
+
return nil unless attributes.is_a?(Hash)
|
88
|
+
self.class.swagger_types.each_pair do |key, type|
|
89
|
+
if type =~ /^Array<(.*)>/i
|
90
|
+
# check to ensure the input is an array given that the the attribute
|
91
|
+
# is documented as an array but the input is not
|
92
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
+
public_method("#{key}=").call(
|
94
|
+
attributes[self.class.attribute_map[key]]
|
95
|
+
.map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
|
96
|
+
)
|
97
|
+
end
|
98
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
99
|
+
public_method("#{key}=").call(
|
100
|
+
OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
|
101
|
+
)
|
102
|
+
end
|
103
|
+
# or else data not found in attributes(hash), not an issue as the data can be optional
|
104
|
+
end
|
105
|
+
|
106
|
+
self
|
107
|
+
end
|
108
|
+
# rubocop:enable Metrics/AbcSize, Layout/EmptyLines
|
109
|
+
|
110
|
+
# Returns the string representation of the object
|
111
|
+
# @return [String] String presentation of the object
|
112
|
+
def to_s
|
113
|
+
to_hash.to_s
|
114
|
+
end
|
115
|
+
|
116
|
+
# Returns the object in the form of hash
|
117
|
+
# @return [Hash] Returns the object in the form of hash
|
118
|
+
def to_hash
|
119
|
+
hash = {}
|
120
|
+
self.class.attribute_map.each_pair do |attr, param|
|
121
|
+
value = public_method(attr).call
|
122
|
+
next if value.nil? && !instance_variable_defined?("@#{attr}")
|
123
|
+
hash[param] = _to_hash(value)
|
124
|
+
end
|
125
|
+
hash
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
# Outputs non-array value in the form of hash
|
131
|
+
# For object, use to_hash. Otherwise, just return the value
|
132
|
+
# @param [Object] value Any valid value
|
133
|
+
# @return [Hash] Returns the value in the form of hash
|
134
|
+
def _to_hash(value)
|
135
|
+
if value.is_a?(Array)
|
136
|
+
value.compact.map { |v| _to_hash(v) }
|
137
|
+
elsif value.is_a?(Hash)
|
138
|
+
{}.tap do |hash|
|
139
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
140
|
+
end
|
141
|
+
elsif value.respond_to? :to_hash
|
142
|
+
value.to_hash
|
143
|
+
else
|
144
|
+
value
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
# rubocop:enable Lint/UnneededCopDisableDirective
|