Module: Rubix::Associations::HasManyUserMacros

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

Instance Method Summary collapse

Instance Method Details

#user_macro_idsObject


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

def user_macro_ids
  return @user_macro_ids if @user_macro_ids
  return unless @user_macros
  @user_macro_ids = @user_macros.map(&:id)
end

#user_macro_ids=(umids) ⇒ Object


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

def user_macro_ids= umids
  return unless umids
  @user_macro_ids = umids
end

#user_macro_paramsObject


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

def user_macro_params
  return [] unless user_macros
  user_macros.map { |um| { 'macro' => um.macro_name, 'value' => um.value } }
end

#user_macrosObject


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

def user_macros
  return @user_macros if @user_macros
  return unless @user_macro_ids
  @user_macros = @user_macro_ids.map { |umid| UserMacro.find(:id => umid) }
end

#user_macros=(hs) ⇒ Object


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

def user_macros= hs
  return unless hs
  @user_macros    = hs
  @user_macro_ids = hs.map(&:id)
end