module PIM::OptionLists
Public Instance Methods
all_option_lists()
click to toggle source
# File pim.rb, line 4188 def all_option_lists option_lists = {} option_lists.merge!(@module_option_lists) if @module_option_lists add_parent_objects(option_lists) { |p| p.module_option_lists } option_lists end
check_option_list!(option_list, message = nil, ignore = false)
click to toggle source
# File pim.rb, line 4199 def check_option_list! option_list, message = nil, ignore = false return if !option_list or option_list.is_a? Class option_list = option_list.name if option_list.is_a? PIM::OptionList if !exists_option_list?(option_list) return false if ignore message = message || "Option list '#{option_list.to_sym}' is not defined" raise message end return true end
create_option_list(option_list_hash)
click to toggle source
# File pim.rb, line 4183 def create_option_list option_list_hash # TODO: Add code to create an option list using a hash definition, e.g. from YAML raise "Not yet implemented" end
exists_option_list?(option_list)
click to toggle source
# File pim.rb, line 4179 def exists_option_list? option_list option_list and all_option_lists.has_key?(to_sym(option_list)) end
module_option_lists()
click to toggle source
# File pim.rb, line 4195 def module_option_lists @module_option_lists ||= {} end
option_list(name, *options, &block)
click to toggle source
# File pim.rb, line 4153 def option_list name, *options, &block name = to_sym(name) if not options.empty? or not block.nil? if module_option_lists.has_key?(name) unless data_module.has_option?(:ignore_defined_option_lists) raise "Option list with name '#{name}' is already defined in data model #{self}" else return module_option_lists[name] end end option_list = PIM::OptionListBuilder.build_option_list(data_module, name, *options, &block) module_option_lists[name] = option_list elsif name.is_a?(PIM::OptionList) option_list = name else option_list = all_option_lists[name] end option_list end
option_lists_as_json()
click to toggle source
# File pim.rb, line 4210 def option_lists_as_json option_lists = {} all_option_lists.sort.each do |key, option_list| option_lists[key] = option_list end as_json(option_lists) end
service_option_list(name)
click to toggle source
Define a ‘service’ option list FIXME: Allow specifying a service different form the current data model!
# File pim.rb, line 4147 def service_option_list name option_list name do service end end