Module: Rubix::Associations::HasManyTemplates

Included in:
Host
Defined in:
lib/rubix/associations/has_many_templates.rb

Instance Method Summary collapse

Instance Method Details

#template_idsObject


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

def template_ids
  return @template_ids if @template_ids
  return unless @templates
  @template_ids = @templates.map(&:id)
end

#template_ids=(tids) ⇒ Object


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

def template_ids= tids
  return unless tids
  @template_ids = tids
end

#template_paramsObject


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

def template_params
  return [] unless template_ids
  template_ids.map { |tid| { 'templateid' => tid } }
end

#templatesObject


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

def templates
  return @templates if @templates
  return unless @template_ids
  @templates = @template_ids.map { |tid| Template.find(:id => tid) }
end

#templates=(hs) ⇒ Object


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

def templates= hs
  return unless hs
  @templates    = hs
  @template_ids = hs.map(&:id)
end