Class: Shoulda::Matchers::ActiveModel::RequireAValidTelephoneMatcher
- Inherits:
-
ValidationMatcher
- Object
- ValidationMatcher
- Shoulda::Matchers::ActiveModel::RequireAValidTelephoneMatcher
- Defined in:
- lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #from(locale) ⇒ Object
-
#initialize(attribute) ⇒ RequireAValidTelephoneMatcher
constructor
A new instance of RequireAValidTelephoneMatcher.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute) ⇒ RequireAValidTelephoneMatcher
Returns a new instance of RequireAValidTelephoneMatcher.
11 12 13 14 |
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 11 def initialize(attribute) @attribute = attribute @options = {} end |
Instance Method Details
#description ⇒ Object
21 22 23 |
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 21 def description "require #{@attribute} to be a valid telephone number" end |
#from(locale) ⇒ Object
16 17 18 19 |
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 16 def from(locale) @options[:locale] = locale self end |
#matches?(subject) ⇒ Boolean
25 26 27 28 29 |
# File 'lib/validates_telephone/shoulda-matchers/require_a_valid_telephone_matcher.rb', line 25 def matches?(subject) super(subject) disallows_invalid_value and allows_valid_value end |