Method: YARD::Options#method_missing
- Defined in:
- lib/yard/options.rb
#method_missing(meth, *args, &block) ⇒ Object
Note:
It is not recommended to set and access unregistered keys on an Options object. Instead, register the attribute before using it.
Handles setting and accessing of unregistered keys similar to an OpenStruct object.
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/yard/options.rb', line 170 def method_missing(meth, *args, &block) if meth.to_s =~ /^(.+)=$/ log.debug "Attempting to set unregistered key #{$1} on #{self.class}" instance_variable_set("@#{$1}", args.first) elsif args.empty? log.debug "Attempting to access unregistered key #{meth} on #{self.class}" instance_variable_defined?("@#{meth}") ? instance_variable_get("@#{meth}") : nil else super end end |