Class: Gapic::Model::Method::HttpAnnotation::HttpBinding
- Inherits:
-
Object
- Object
- Gapic::Model::Method::HttpAnnotation::HttpBinding
- Defined in:
- lib/gapic/model/method/http_annotation.rb
Overview
A single Http binding.
Instance Method Summary collapse
-
#body ⇒ String
The body specified for the given method in proto or an empty string if not specified.
-
#body? ⇒ Boolean
Whether method has body specified in proto.
-
#initialize(binding) ⇒ HttpBinding
constructor
A new instance of HttpBinding.
-
#path ⇒ String
A method path or an empty string if not present.
-
#path? ⇒ Boolean
Whether a method path is present and non-empty.
-
#routing_params ⇒ Array<String>
The segment key names.
-
#routing_params? ⇒ Boolean
Whether any routing params are present.
-
#routing_params_with_patterns ⇒ Array<Array<String>>
The segment key names and their corresponding paterns, including the
*
pattern implied for the named segments without pattern explicitly specified. -
#verb ⇒ Symbol?
The http verb for this method.
-
#verb? ⇒ Boolean
Whether a http verb is present for this method.
Constructor Details
#initialize(binding) ⇒ HttpBinding
Returns a new instance of HttpBinding.
98 99 100 |
# File 'lib/gapic/model/method/http_annotation.rb', line 98 def initialize binding @binding = binding end |
Instance Method Details
#body ⇒ String
The body specified for the given method in proto or an empty string if not specified
178 179 180 |
# File 'lib/gapic/model/method/http_annotation.rb', line 178 def body @binding&.body || "" end |
#body? ⇒ Boolean
Whether method has body specified in proto
169 170 171 |
# File 'lib/gapic/model/method/http_annotation.rb', line 169 def body? !body.empty? end |
#path ⇒ String
A method path or an empty string if not present
130 131 132 133 |
# File 'lib/gapic/model/method/http_annotation.rb', line 130 def path return "" unless verb_path verb_path[1] end |
#path? ⇒ Boolean
Whether a method path is present and non-empty
122 123 124 |
# File 'lib/gapic/model/method/http_annotation.rb', line 122 def path? !path.empty? end |
#routing_params ⇒ Array<String>
The segment key names.
161 162 163 |
# File 'lib/gapic/model/method/http_annotation.rb', line 161 def routing_params routing_params_with_patterns.map { |param, _| param } end |
#routing_params? ⇒ Boolean
Whether any routing params are present
139 140 141 |
# File 'lib/gapic/model/method/http_annotation.rb', line 139 def routing_params? routing_params.any? end |
#routing_params_with_patterns ⇒ Array<Array<String>>
The segment key names and their corresponding paterns,
including the *
pattern implied for the named segments
without pattern explicitly specified.
149 150 151 152 153 154 155 |
# File 'lib/gapic/model/method/http_annotation.rb', line 149 def routing_params_with_patterns @routing_params_with_patterns ||= begin Gapic::UriTemplate.parse_arguments(path).map do |name, pattern| [name, pattern.empty? ? "*" : pattern] end end end |
#verb ⇒ Symbol?
The http verb for this method
114 115 116 |
# File 'lib/gapic/model/method/http_annotation.rb', line 114 def verb verb_path[0] if verb_path end |
#verb? ⇒ Boolean
Whether a http verb is present for this method
106 107 108 |
# File 'lib/gapic/model/method/http_annotation.rb', line 106 def verb? !verb.nil? end |