Module: HammerCLISAM::ExcludeOptions::ClassMethods
- Defined in:
- lib/hammer_cli_sam/exclude_mixin.rb
Instance Method Summary collapse
-
#exclude_options(*options) ⇒ Object
when #exclude_options is called on a command class, we take those options and generate a #recognised_options method overriding the parent’s #recognised_options to pull out the options we don’t want.
Instance Method Details
#exclude_options(*options) ⇒ Object
when #exclude_options is called on a command class, we take those options and generate a #recognised_options method overriding the parent’s #recognised_options to pull out the options we don’t want.
it probably seems odd that we’re calling #instance_eval here if this is to be modifying a class. Since we’re in the ClassMethods module while will be applied to the class, in the current scope, self is the class, so our current instance is the class definition.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/hammer_cli_sam/exclude_mixin.rb', line 21 def (*) instance_eval " def recognised_options\n super.reject! do |opt|\n \#{options.map { |opt| /\#{opt.to_s}/ }.inspect}.reduce(false) do |reduced, regex|\n reduced || (opt.attribute_name =~ regex)\n end\n end\n end\n eoruby\nend\n" |