Class: Shoulda::Matchers::ActiveModel::RequireAValidTelephoneMatcher
- Inherits:
-
ValidationMatcher
- Object
- ValidationMatcher
- Shoulda::Matchers::ActiveModel::RequireAValidTelephoneMatcher
- Defined in:
- lib/validates_telephone/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.
12 13 14 15 |
# File 'lib/validates_telephone/require_a_valid_telephone_matcher.rb', line 12 def initialize(attribute) @attribute = attribute @options = {} end |
Instance Method Details
#description ⇒ Object
22 23 24 |
# File 'lib/validates_telephone/require_a_valid_telephone_matcher.rb', line 22 def description "require #{@attribute} to be a valid telephone number" end |
#from(locale) ⇒ Object
17 18 19 20 |
# File 'lib/validates_telephone/require_a_valid_telephone_matcher.rb', line 17 def from(locale) @options[:locale] = locale self end |
#matches?(subject) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/validates_telephone/require_a_valid_telephone_matcher.rb', line 26 def matches?(subject) super(subject) disallows_invalid_value and allows_valid_value end |