Class: Drnbench::RequestResponse::RequestPattern::Pattern
- Inherits:
-
Object
- Object
- Drnbench::RequestResponse::RequestPattern::Pattern
- Defined in:
- lib/drnbench/request-response/request-pattern.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source, group) ⇒ Pattern
constructor
A new instance of Pattern.
- #path ⇒ Object
- #to_request ⇒ Object
Constructor Details
#initialize(source, group) ⇒ Pattern
Returns a new instance of Pattern.
169 170 171 172 |
# File 'lib/drnbench/request-response/request-pattern.rb', line 169 def initialize(source, group) @source = source @group = group end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
167 168 169 |
# File 'lib/drnbench/request-response/request-pattern.rb', line 167 def group @group end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
167 168 169 |
# File 'lib/drnbench/request-response/request-pattern.rb', line 167 def source @source end |
Class Method Details
.valid_source?(source) ⇒ Boolean
159 160 161 162 163 164 |
# File 'lib/drnbench/request-response/request-pattern.rb', line 159 def valid_source?(source) return true if source.is_a?(String) return false if source.is_a?(Array) return !source.has_key?("patterns") if source.is_a?(Hash) false end |
Instance Method Details
#path ⇒ Object
174 175 176 177 178 179 180 |
# File 'lib/drnbench/request-response/request-pattern.rb', line 174 def path if @source.is_a?(String) @source else @source["path"] end end |
#to_request ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/drnbench/request-response/request-pattern.rb', line 182 def to_request if @source.is_a?(String) request = { "path" => @source } else request = @source end request["host"] ||= @group.host request["port"] ||= @group.port request["method"] ||= @group.method request["timeout"] ||= @group.timeout request end |