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

hash.present? conflict between rails 4.2.4 and tins 1.x #67

Closed
serixscorpio opened this issue Oct 7, 2015 · 3 comments
Closed

hash.present? conflict between rails 4.2.4 and tins 1.x #67

serixscorpio opened this issue Oct 7, 2015 · 3 comments

Comments

@serixscorpio
Copy link
Contributor

Recently when I attempted to upgrade to use rails 4.2.4, along with stupidedi, I came across a method definition conflict.
stupidedi depends on term-ansicolor, which depends on tins. Tins add present? method to Hash.
rails 4.2.4 also add present? method to Hash in its active support core extensions.
The semantics of the above two methods are different.
Does stupidedi depend on term-ansicolor only because of being able to color the terminal output? If so, is there some way I can turn it off and remove that dependency? or other suggestions? Thanks.

@serixscorpio
Copy link
Contributor Author

Actually, an update here. It seems stupidedi uses present? widely as an internal interface (perhaps?) See lib/ruby/blank.rb

class Object
  def present?
    true
  end
end

This conflicts with rails present?.

@kputnam
Copy link
Owner

kputnam commented Nov 24, 2015

Sorry for the slow response. Yes, you can simply remove the dependency on term-ansicolor and the terminal output will be ordinary black-and-white.

However, you are correct that present? is regrettably defined by monkey-patching the Object class. This method and a few others are all defined in lib/ruby.

There was a proposal in the comments of #48 to use Ruby's refinements to limit the scope of these patches, but I don't think anyone is working on it. I don't really have the time to work on that nor test that it fixes the interaction with Rails, but would gladly accept a pull request. This issue has affected many people, and is a big regret!

@kputnam
Copy link
Owner

kputnam commented Jan 27, 2016

Fixed by #72

@kputnam kputnam closed this as completed Jan 27, 2016
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