Class: MethodInfo::OptionHandler
- Defined in:
- lib/method_info/option_handler.rb
Constant Summary collapse
- @@custom_default_options =
{}
Class Method Summary collapse
- .default_options ⇒ Object
- .default_options=(options = {}) ⇒ Object
- .default_profile ⇒ Object
- .handle(object, options = {}) ⇒ Object
- .process_options(options = {}) ⇒ Object
Class Method Details
.default_options ⇒ Object
43 44 45 |
# File 'lib/method_info/option_handler.rb', line 43 def self. @@custom_default_options end |
.default_options=(options = {}) ⇒ Object
39 40 41 |
# File 'lib/method_info/option_handler.rb', line 39 def self.( = {}) @@custom_default_options = end |
.default_profile ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/method_info/option_handler.rb', line 22 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 |
.handle(object, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/method_info/option_handler.rb', line 7 def self.handle(object, = {}) = () format = .delete(:format) ancestor_method_structure = AncestorMethodStructure.build(object, ) 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 |
.process_options(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/method_info/option_handler.rb', line 47 def self.( = {}) defaults = default_profile.merge(@@custom_default_options) = .keys - defaults.keys if .empty? defaults.merge() else raise ArgumentError.new("Unsupported options: " + .map { |k| k.to_s }.sort.join(', ')) end end |