Class: Shoulda::Matchers::ActiveModel::RequireAValidRfcMatcher
- Inherits:
-
ValidationMatcher
- Object
- ValidationMatcher
- Shoulda::Matchers::ActiveModel::RequireAValidRfcMatcher
- Defined in:
- lib/validates_rfc/require_a_valid_rfc_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #for_company ⇒ Object
- #for_person ⇒ Object
-
#initialize(attribute) ⇒ RequireAValidRfcMatcher
constructor
A new instance of RequireAValidRfcMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ RequireAValidRfcMatcher
Returns a new instance of RequireAValidRfcMatcher.
13 14 15 16 |
# File 'lib/validates_rfc/require_a_valid_rfc_matcher.rb', line 13 def initialize(attribute) @type = :both super end |
Instance Method Details
#description ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/validates_rfc/require_a_valid_rfc_matcher.rb', line 28 def description case @type when :both then 'requires a valid RFC' when :company then 'requires a valid company RFC' when :person then 'requires a valid person RFC' end end |
#failure_message ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/validates_rfc/require_a_valid_rfc_matcher.rb', line 36 def case @type when :both then 'does not require a valid RFC' when :company then 'does not require a valid company RFC' when :person then 'does not require a valid person RFC' end end |
#for_company ⇒ Object
18 19 20 21 |
# File 'lib/validates_rfc/require_a_valid_rfc_matcher.rb', line 18 def for_company @type = :company self end |
#for_person ⇒ Object
23 24 25 26 |
# File 'lib/validates_rfc/require_a_valid_rfc_matcher.rb', line 23 def for_person @type = :person self end |
#matches?(subject) ⇒ Boolean
44 45 46 47 48 49 50 51 52 |
# File 'lib/validates_rfc/require_a_valid_rfc_matcher.rb', line 44 def matches?(subject) super(subject) case @type when :both then check_for_both_types when :company then check_for_company_type when :person then check_for_person_type end end |