class TSAdmin::TrafficServer::RemapEntry

Attributes

from[RW]
id[RW]
to[RW]
type[RW]

Public Class Methods

new(ts, type, from, to) click to toggle source
# File lib/ts-admin/traffic_server.rb, line 28
def initialize(ts, type, from, to)
  @ts = ts
  @type = type.to_sym
  @from = from.downcase
  @to = to.downcase
  @id = Digest::SHA1.hexdigest(@from)
end

Public Instance Methods

errors() click to toggle source
# File lib/ts-admin/traffic_server.rb, line 40
def errors
  e = []
  e << :type_invalid unless [:map, :redirect].include?(@type)
  e << :from_invalid unless valid_url?(@from)
  e << :to_invalid unless valid_url?(@to)
  e << :duplicate_entry unless @ts.remap_entries.get_from(@from).select{|e| e != self}.count == 0
  e.compact.uniq
end
valid?() click to toggle source
# File lib/ts-admin/traffic_server.rb, line 36
def valid?
  errors.count == 0
end

Private Instance Methods

valid_url?(url) click to toggle source
# File lib/ts-admin/traffic_server.rb, line 51
def valid_url?(url)
  !!(url =~ URI::regexp) rescue false
end