Module: Thor::InheritedOptions::ClassMethods
- Defined in:
- lib/web_crawler/cli/thor_inherited_options.rb
Instance Method Summary collapse
Instance Method Details
#inherited_method_options(from_action, for_action = nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/web_crawler/cli/thor_inherited_options.rb', line 15 def (from_action, for_action = nil) tasks[from_action.to_s]..each do |name, option| option_hash = option_to_hash(option).symbolize_keys option_hash.merge! for: for_action.to_s if for_action option_hash[:desc] = option_hash[:description] method_option name, option_hash end end |
#option_to_hash(option) ⇒ Object
9 10 11 12 13 |
# File 'lib/web_crawler/cli/thor_inherited_options.rb', line 9 def option_to_hash(option) values = option.instance_variables.map { |v| option.instance_variable_get v } keys = option.instance_variables.map { |sym| sym.to_s.sub('@', '') } Hash[keys.zip values] end |