Sha256: b47f5146c25e3ad61cc7d33dcfb667a36449a363c9336e49b10521b7efca95d0
Contents?: true
Size: 1.69 KB
Versions: 3
Compression:
Stored size: 1.69 KB
Contents
require 'method_info/ancestor_method_structure' module MethodInfo class OptionHandler @@custom_default_options = {} def self.handle(object, options = {}) processed_options = process_options(options) format = processed_options.delete(:format) ancestor_method_structure = AncestorMethodStructure.build(object, processed_options) if format == :string ancestor_method_structure.to_s elsif format == :array ancestor_method_structure.to_a elsif format raise(ArgumentError.new("Unknown value for :format option. Supported values are: nil, :array, :string")) else puts ancestor_method_structure end end def self.default_profile { :ancestors_to_show => [], :ancestors_to_exclude => [], :format => nil, :include_names_of_excluded_ancestors => true, :include_names_of_methodless_ancestors => true, :private_methods => false, :protected_methods => false, :singleton_methods => true, :public_methods => true, :enable_colors => false, :suppress_slowness_warning => false, :match => nil } end def self.default_options=(options = {}) @@custom_default_options = options end def self.default_options @@custom_default_options end def self.process_options(options = {}) defaults = default_profile.merge(@@custom_default_options) unknown_options = options.keys - defaults.keys if unknown_options.empty? defaults.merge(options) else raise ArgumentError.new("Unsupported options: " + unknown_options.map { |k| k.to_s }.sort.join(', ')) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
method_info-0.1.11 | lib/method_info/option_handler.rb |
method_info-0.1.10 | lib/method_info/option_handler.rb |
method_info-0.1.9 | lib/method_info/option_handler.rb |