Class: Shoulda::Matchers::ActiveModel::HostNameMatcher

Inherits:
ValidationMatcher
  • Object
show all
Defined in:
lib/validates_host/shoulda-matchers/host_name_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(attribute) ⇒ HostNameMatcher

Returns a new instance of HostNameMatcher.



11
12
13
# File 'lib/validates_host/shoulda-matchers/host_name_matcher.rb', line 11

def initialize(attribute)
  @attribute = attribute
end

Instance Method Details

#descriptionObject



15
16
17
# File 'lib/validates_host/shoulda-matchers/host_name_matcher.rb', line 15

def description
  "require #{@attribute} to be a valid host name"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/validates_host/shoulda-matchers/host_name_matcher.rb', line 19

def matches?(subject)
  super(subject)

  disallows_invalid_value and allows_valid_value
end