Class ActiveMatchers::Matchers::ValidationMatcher
In: lib/matchers/validation_matcher.rb
Parent: Object

Methods

failure_message   if   matches?   new   one_of   starting_with   to   to_be_unique   using  

Public Class methods

[Source]

   # File lib/matchers/validation_matcher.rb, line 4
4:       def initialize(type, *attributes)
5:         @type = type
6:         @attributes = attributes
7:       end

Public Instance methods

[Source]

    # File lib/matchers/validation_matcher.rb, line 25
25:       def failure_message
26:         "Error: #{@error}"
27:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 39
39:       def if(&block)
40:         @if = block
41:         self
42:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 9
 9:       def matches?(model)
10:         @model = model
11:         case @type
12:         when :require
13:           confirm_required(&@if)
14:         when :unique
15:           confirm_unique
16:         when :one_of_many
17:           confirm_one_of_many
18:         when :length
19:           confirm_length
20:         else
21:           false
22:         end
23:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 44
44:       def one_of(*attributes)
45:         @attributes = attributes
46:         @type = :one_of_many
47:         self
48:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 55
55:       def starting_with(base)
56:         @base = base
57:         self
58:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 50
50:       def to(length)
51:         @length = length
52:         self
53:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 29
29:       def to_be_unique
30:         @type = :unique
31:         self
32:       end

[Source]

    # File lib/matchers/validation_matcher.rb, line 34
34:       def using(attributes={})
35:         @base_attributes = attributes
36:         self
37:       end

[Validate]