Skip to content
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

Builder method_missing overrides even Object and Kernel methods #18

Open
aks opened this issue Apr 7, 2022 · 0 comments
Open

Builder method_missing overrides even Object and Kernel methods #18

aks opened this issue Apr 7, 2022 · 0 comments

Comments

@aks
Copy link

aks commented Apr 7, 2022

The XmlMarkup class overrides any method that is not part of its class, including Object and/or Kernel methods.

Simple examples:

[2] DEVELOPMENT(main)> xml = Builder::XmlMarkup.new
=> <is_a?>String</is_a?><inspect/>

I'm thinking that the is_a? method is being applied because irb is evaluating the argument.

[3] DEVELOPMENT(main)> puts xml.inspect
<is_a?>String</is_a?><inspect/><inspect/>
=> nil

Yep. An explicit use of inspect causes another tag to be inserted.

It should be possible to use Ruby's Object and/or Kernel methods on an XmlMarkup instance without getting matching tags automatically inserted.

Some exceptions, like p and name, may need to be allowed, since those methods might also be common tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant