Class: Cucumber::Core::Test::Result::StrictConfiguration
- Inherits:
-
Object
- Object
- Cucumber::Core::Test::Result::StrictConfiguration
- Defined in:
- lib/cucumber/core/test/result.rb
Overview
Handles the strict settings for the result types that are affected by the strict options (that is the STRICT_AFFECTED_TYPES).
Instance Attribute Summary collapse
-
#settings ⇒ Object
writeonly
Sets the attribute settings.
Instance Method Summary collapse
-
#initialize(strict_types = []) ⇒ StrictConfiguration
constructor
A new instance of StrictConfiguration.
- #merge!(other) ⇒ Object
- #set?(type) ⇒ Boolean
- #set_strict(setting, type = nil) ⇒ Object
- #strict?(type = nil) ⇒ Boolean
Constructor Details
#initialize(strict_types = []) ⇒ StrictConfiguration
Returns a new instance of StrictConfiguration.
285 286 287 288 289 290 |
# File 'lib/cucumber/core/test/result.rb', line 285 def initialize(strict_types = []) @settings = STRICT_AFFECTED_TYPES.map { |t| [t, :default] }.to_h strict_types.each do |type| set_strict(true, type) end end |
Instance Attribute Details
#settings=(value) ⇒ Object
Sets the attribute settings
282 283 284 |
# File 'lib/cucumber/core/test/result.rb', line 282 def settings=(value) @settings = value end |
Instance Method Details
#merge!(other) ⇒ Object
315 316 317 318 319 320 |
# File 'lib/cucumber/core/test/result.rb', line 315 def merge!(other) settings.each_key do |type| set_strict(other.strict?(type), type) if other.set?(type) end self end |
#set?(type) ⇒ Boolean
322 323 324 |
# File 'lib/cucumber/core/test/result.rb', line 322 def set?(type) settings[type] != :default end |
#set_strict(setting, type = nil) ⇒ Object
305 306 307 308 309 310 311 312 313 |
# File 'lib/cucumber/core/test/result.rb', line 305 def set_strict(setting, type = nil) if type.nil? STRICT_AFFECTED_TYPES.each do |t| set_strict(setting, t) end else settings[type] = setting end end |
#strict?(type = nil) ⇒ Boolean
292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/cucumber/core/test/result.rb', line 292 def strict?(type = nil) if type.nil? settings.each do |_key, value| return true if value == true end false else return false unless settings.key?(type) return false unless set?(type) settings[type] end end |