Module: StaticList::Helpers

Defined in:
lib/static_list.rb

Instance Method Summary collapse

Instance Method Details

#static_list_select_options(static_object) ⇒ Object

Localizes all the static codes for select options helper

Example : f.select :hair_color, static_list_select_options(HairColor)



95
96
97
# File 'lib/static_list.rb', line 95

def static_list_select_options(static_object)
  static_object.static_list_codes.map { |code| [t_static_list(code[1], static_object), code[1]] }
end

#t_static_list(code, static_object) ⇒ Object

Localizes a static code For example : t_static_list(@user.hair_color, HairColor)

will read the key hair_color.white



85
86
87
88
# File 'lib/static_list.rb', line 85

def t_static_list(code, static_object)
  return unless code
  t "#{static_object.to_s.demodulize.underscore}.#{static_object.static_list_code_to_sym(code)}"
end