lib/fiksu-af/option_parser/dsl.rb in fiksu-af-1.1.2 vs lib/fiksu-af/option_parser/dsl.rb in fiksu-af-1.1.3
- old
+ new
@@ -18,10 +18,11 @@
# * :title - display title of the group (optional)
# * :description - details about group
# * :priority - order to show groups in help --?
# * :hidden - true if this group's options should only be seen with --?
# * :disabled - (default: false)
+ # * :containing_class - name of class path for this option (for: af_opt_class_path)
# * anything else in this hash can be passed to yield block as defaults for other opt/opt_group invocations
# * yeilds to block if given with extra_stuff in a global space that opt/opt_group calls use as defaults
def opt_group(group_name, *extra_stuff)
# grab information from our yield scope
@@ -76,10 +77,11 @@
# :choices - array of valid choices, e.g: [:blue, :green, :red]
# :set - (:value_to_set_target_variable) value to set if option specified (use for switches where --blue means set @color = 'blue')
# :no_accessor - (:do_not_create_accessor) don't class_eval 'attr_accessor :#{target_variable}'
# :var - (:target_variable) name of instance variable to set
# :target_container - name of object to set instance value
+ # :containing_class - name of class path for this option (for: af_opt_class_path)
#
# if block is passed it is used as :method
#
def opt(long_name, *extra_stuff, &b)
factory_hash = opt_get_top_of_stack
@@ -205,10 +207,10 @@
end
end
# Add long_name to OptionStore if it's not present. Otherwise, retrieve the value
# associated with that key and merge the value into factory_hash
- OptionStore.factory(self).get_option(long_name).merge!(factory_hash)
+ OptionStore.factory(factory_hash[:containing_class] || self).get_option(long_name).merge!(factory_hash)
end
def opt_check(var_name, *extra_stuff, &b)
factory_hash = {}
factory_hash[:target_variable] = var_name[0..-1]