-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create accessor methods to XMLRPC::Config #40
Conversation
This makes it easier to add accessors for the other items.
lib/xmlrpc/config.rb
Outdated
:ENABLE_MULTICALL, | ||
:ENABLE_INTROSPECTION | ||
].each do |option| | ||
define_singleton_method("#{option.downcase}") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you append ?
only for ENABLE_*
?
For example, enable_nil_create?
for :ENABLE_NIL_CREATE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added predicate methods for all the boolean values, and updated the calling code to use the predicates instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
But do we need both of enable_nil_create
and enable_nil_create?
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not. I've removed the enable_nil_create
and friends for the boolean options.
Make it read more like a boolean
lib/xmlrpc/config.rb
Outdated
end | ||
|
||
define_singleton_method("#{option.downcase}=") do |value| | ||
module_eval do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this module_eval
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we don't. I copy-pasted this from some code we had for changing the config options, but that was run from another module than Config
.
I'ts gone now.
Thanks. |
Currently the config is made up of a number of constants, changing the config does require some boilerplate to redefine constants. An example:
This change adds accessor methods to the Config module, so you can simply write them like this:
It still uses the constants under water, which means it is fully backwards compatible (which was the big objection in #39 )