Module: Rubix::Associations::HasManyHosts

Included in:
HostGroup, Template
Defined in:
lib/rubix/associations/has_many_hosts.rb

Instance Method Summary collapse

Instance Method Details

#host_idsObject


22
23
24
25
26
# File 'lib/rubix/associations/has_many_hosts.rb', line 22

def host_ids
  return @host_ids if @host_ids
  return unless @hosts
  @host_ids = @hosts.map(&:id)
end

#host_ids=(hids) ⇒ Object


17
18
19
20
# File 'lib/rubix/associations/has_many_hosts.rb', line 17

def host_ids= hids
  return unless hids
  @host_ids = hids
end

#hostsObject


11
12
13
14
15
# File 'lib/rubix/associations/has_many_hosts.rb', line 11

def hosts
  return @hosts if @hosts
  return unless @host_ids
  @hosts = @host_ids.map { |hid| Host.find(:id => hid) }
end

#hosts=(hs) ⇒ Object


5
6
7
8
9
# File 'lib/rubix/associations/has_many_hosts.rb', line 5

def hosts= hs
  return unless hs
  @hosts    = hs
  @host_ids = hs.map(&:id)
end