class PIM::OptionListBuilder
Attributes
name[R]
Public Class Methods
build_option_list(data_module, name, *options, &block)
click to toggle source
# File pim.rb, line 4224 def self.build_option_list data_module, name, *options, &block builder = OptionListBuilder.new name, *options DataModuleObject.set_data_module(builder, data_module) builder.instance_exec(&block) if block builder.build end
new(name, *options)
click to toggle source
# File pim.rb, line 4233 def initialize name, *options @name = name @options = OptionList.to_options(*options) @groups = {} @service = nil end
Public Instance Methods
build()
click to toggle source
# File pim.rb, line 4240 def build option_list = PIM::OptionList.new @name, @options, @groups, @service DataModuleObject.set_data_module(option_list, data_module) option_list.model_defined = true option_list end
group(group_name, *options)
click to toggle source
# File pim.rb, line 4256 def group group_name, *options group_namename = to_sym(group_name) unless options.empty? # Create or merge group values and merge options with existing options options = OptionList.to_options(*options) @groups[group_name] ||= [] @groups[group_name] |= options.keys @options.merge!(options) { |k, old_value, new_value| old_value || new_value } end @groups[group_namename] end
option(option_name, label = nil, *group_names)
click to toggle source
# File pim.rb, line 4268 def option option_name, label = nil, *group_names option_name = to_sym(option_name) unless label.nil? and group_names.empty? @options[option_name] ||= label group_names.each do |group_name| group group_name, option_name end end @options[option_name] end
options(*options)
click to toggle source
# File pim.rb, line 4247 def options *options unless options.empty? # Merge with existing options options = OptionList.to_options(*options) @options.merge!(options) end @options end
service()
click to toggle source
# File pim.rb, line 4279 def service @options = nil @groups = nil @service = data_module end