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

Slopping does not contain respond_to_missing? #1176

Closed
Smarre opened this issue Oct 15, 2014 · 2 comments
Closed

Slopping does not contain respond_to_missing? #1176

Smarre opened this issue Oct 15, 2014 · 2 comments
Assignees

Comments

@Smarre
Copy link

Smarre commented Oct 15, 2014

slop.rb, which allows accessing data with help of method_missing, is missing respond_to_missing? which prevents usage of respond_to? to test whether data exists in the response.

I successfully used following piece of code to mitigate the problem:

module Nokogiri
module Decorators
module Slop
def respond_to_missing? name, include_private = false
prefix = implied_xpath_context
list = xpath("#{prefix}#{name.to_s.sub(/^_/, '')}")
return false if list.empty?
true
end
end
end
end

I took the implementation from method_missing in slop.rb, and disregarded args parts as I don’t know what for they are used and if they apply for this one.

@knu
Copy link
Member

knu commented Oct 15, 2014

That makes sense. I'll tackle this later.

@knu knu self-assigned this Oct 15, 2014
@knu
Copy link
Member

knu commented Nov 6, 2014

Done!

@knu knu closed this as completed Nov 6, 2014
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

2 participants