Class: Trebuchet::Strategy::Hostname

Inherits:
Base
  • Object
show all
Defined in:
lib/trebuchet/strategy/hostname.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#feature

Instance Method Summary collapse

Methods inherited from Base

#as_json, #feature_id, #inspect, #name, strategy_name

Constructor Details

#initialize(hostnames) ⇒ Hostname

Returns a new instance of Hostname.



5
6
7
8
9
10
11
# File 'lib/trebuchet/strategy/hostname.rb', line 5

def initialize(hostnames)
  @hostnames = if hostnames.is_a?(Array)
    hostnames
  else
    [hostnames]
  end
end

Instance Attribute Details

#hostnamesObject (readonly)

Returns the value of attribute hostnames.



3
4
5
# File 'lib/trebuchet/strategy/hostname.rb', line 3

def hostnames
  @hostnames
end

Instance Method Details

#exportObject



26
27
28
# File 'lib/trebuchet/strategy/hostname.rb', line 26

def export
  super @hostnames
end

#launch_at?(user, request = nil) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/trebuchet/strategy/hostname.rb', line 13

def launch_at?(user, request = nil)
  return false if request.nil?
  self.hostnames.include?(request.host)
end

#needs_user?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/trebuchet/strategy/hostname.rb', line 18

def needs_user?
  false
end

#to_sObject



22
23
24
# File 'lib/trebuchet/strategy/hostname.rb', line 22

def to_s
  "hostnames (#{hostnames.empty? ? 'none' : hostnames.join(', ')})"
end