Module: Rubix::Associations::HasManyHostGroups

Included in:
Host, Template
Defined in:
lib/rubix/associations/has_many_host_groups.rb

Instance Method Summary collapse

Instance Method Details

#host_group_idsObject



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

def host_group_ids
  return @host_group_ids if @host_group_ids
  return unless @host_groups
  @host_group_ids = @host_groups.map(&:id)
end

#host_group_ids=(hgids) ⇒ Object



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

def host_group_ids= hgids
  return unless hgids
  @host_group_ids = hgids
end

#host_group_paramsObject



28
29
30
31
# File 'lib/rubix/associations/has_many_host_groups.rb', line 28

def host_group_params
  return [] unless host_group_ids
  host_group_ids.map { |hid| { 'groupid' => hid } }
end

#host_groupsObject



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

def host_groups
  return @host_groups if @host_groups
  return unless @host_group_ids
  @host_groups = @host_group_ids.map { |hgid| HostGroup.find(:id => hgid) }
end

#host_groups=(hs) ⇒ Object



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

def host_groups= hs
  return unless hs
  @host_groups    = hs
  @host_group_ids = hs.map(&:id)
end