Class: TSAdmin::TrafficServer::RemapEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/ts-admin/traffic_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ts, type, from, to) ⇒ RemapEntry

Returns a new instance of RemapEntry.



28
29
30
31
32
33
34
# 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

Instance Attribute Details

#fromObject

Returns the value of attribute from.



26
27
28
# File 'lib/ts-admin/traffic_server.rb', line 26

def from
  @from
end

#idObject

Returns the value of attribute id.



26
27
28
# File 'lib/ts-admin/traffic_server.rb', line 26

def id
  @id
end

#toObject

Returns the value of attribute to.



26
27
28
# File 'lib/ts-admin/traffic_server.rb', line 26

def to
  @to
end

#typeObject

Returns the value of attribute type.



26
27
28
# File 'lib/ts-admin/traffic_server.rb', line 26

def type
  @type
end

Instance Method Details

#errorsObject



40
41
42
43
44
45
46
47
# 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?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/ts-admin/traffic_server.rb', line 36

def valid?
  errors.count == 0
end