lib/ballast/request_domain_matcher.rb in ballast-1.9.3 vs lib/ballast/request_domain_matcher.rb in ballast-2.0.0
- old
+ new
@@ -7,24 +7,24 @@
# A small class to match requests basing on the domain.
#
# @attribute domains
# @return [Array] The list of domains which mark a positive match.
# @attribute replace_pattern
- # @return [String|Regexp] A optional pattern to replace in the request host. See `String#gsub`.
+ # @return [String|Regexp] A optional pattern to manipulate the request host before trying the match. See `String#gsub`.
# @attribute replace_string
- # @return [String] A string to use for replacement in the request host. See `String#gsub`.
+ # @return [String] A string to manipulate the request host before trying the match. See `String#gsub`.
# @attribute replace_block
- # @return [Proc] A block to use for replacement in the request host. See `String#gsub`.
+ # @return [Proc] A block to use to manipulate the request host before trying the match. See `String#gsub`.
class RequestDomainMatcher
attr_accessor :domains, :replace_pattern, :replace_string, :replace_block
# Creates a new matcher.
#
# @param domains [String|Array] The list of domains which mark a positive match.
- # @param replace_pattern [String|Regexp] A optional pattern to replace in the request host. See `String#gsub`.
- # @param replace_string [String] A string to use for replacement in the request host. See `String#gsub`.
- # @param replace_block [Proc] A block to use for replacement in the request host. See `String#gsub`.
+ # @param replace_pattern [String|Regexp] A optional pattern to manipulate the request host before trying the match. See `String#gsub`.
+ # @param replace_string [String] A string to manipulate the request host before trying the match. See `String#gsub`.
+ # @param replace_block [Proc] A block to use to manipulate the request host before trying the match. See `String#gsub`.
def initialize(domains, replace_pattern = /\.dev$/, replace_string = "", &replace_block)
@domains = domains.ensure_array
@replace_pattern = replace_pattern
@replace_string = replace_string
@replace_block = replace_block
@@ -37,6 +37,6 @@
def matches?(request)
final_host = @replace_block ? request.host.gsub(@replace_pattern, &@replace_block) : request.host.gsub(@replace_pattern, @replace_string)
@domains.include?(final_host)
end
end
-end
\ No newline at end of file
+end