Closed bf4 closed 9 years ago
I'm not sure what the ideal return value for #to_int is, but nil doesn't work and 0 doesn't seem to have any ill-effects.
@tenderlove any thoughts on the meaning of define_method(:to_int) { 0 } on serialization of {null: null}.to_yaml?
Ref: Psych::Visitors::YAMLTree
def key? target
@obj_to_node.key? target.object_id
rescue NoMethodError
false
end
should psych also rescue a TypeError, instead of just NoMethodError?
I may also open this as a bug in ruby/psych that it only rescues a NoMethodError, not TypeError.. we'll see
failures are rubocop..
If you rebase from master
, the RuboCop failures should be fixed. While you’re rebasing, would you mind doing an interactive rebasing and squashing these changes into a single commit? Ideally, the tests and related code changes would be in a single, atomic commit, in case they need to be reverted.
I have mixed feelings about the content of this change. If seems like quite a dirty hack. I’ll leave it up to @avdi as to whether this should be merged or not. Perhaps this problem is better addressed in the twitter
gem directly than at the library level?
@sferik in the meantime, would you like a PR to add to_int
to the Twitter::NullObject
? That was my original patch before I dug down into it.
@bf4 I would like @avdi to weigh-in first. If it’s an urgent issue for you, feel free to monkey patch your application.
@sferik not urgent at all, in fact my Gemfile is now
# until https://github.com/avdi/naught/pull/67 is merged
gem 'naught', github: 'bf4/naught', branch: 'bf/fix_black_hole'
gem 'twitter'
@sferik Thanks for taking care of this. I guess it couldn't be merged anymore?
I took a different approach to solving this problem, defining to_int
as an implicit conversion.
:smile:
Released in version 1.1.0.
Fixes #66 See there for details