Module: Pre::FakeValidation
- Defined in:
- lib/pre/fake_validation.rb
Instance Method Summary collapse
- #stub_validator(strategy, result) ⇒ Object
- #stub_validators(*stubs) ⇒ Object
- #stubbed_validators ⇒ Object
- #validate(strategy) ⇒ Object
Instance Method Details
#stub_validator(strategy, result) ⇒ Object
4 5 6 |
# File 'lib/pre/fake_validation.rb', line 4 def stub_validator strategy, result stubbed_validators[strategy] = result end |
#stub_validators(*stubs) ⇒ Object
8 9 10 11 12 |
# File 'lib/pre/fake_validation.rb', line 8 def stub_validators *stubs stubs.each_slice(2) do |strategy, result| stub_validator strategy, result end end |
#stubbed_validators ⇒ Object
14 15 16 |
# File 'lib/pre/fake_validation.rb', line 14 def stubbed_validators @stubbed_validators ||= {} end |
#validate(strategy) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/pre/fake_validation.rb', line 18 def validate strategy return super unless stubbed_validators.has_key? strategy result = stubbed_validators[strategy] return result.call self if result.respond_to? :call result end |