monkey patch of the day – activesupport vs. json_pure vs. Ruby 1.8

July 25, 2010 Alex Chaffee

The error:

/Library/Ruby/Gems/1.8/gems/json_pure-1.4.3/lib/json/pure/generator.rb:232:in `__send__': undefined method `except' for #<JSON::Pure::Generator::State:0x102f245b0> (NoMethodError)

The environment: Ruby 1.8.7, DataMapper, dm-types, ActiveSupport, or just

require 'json/pure'
require 'active_support'

(as seen in http://gist.github.com/339528)

My solution:

# workaround for activesupport vs. json_pure vs. Ruby 1.8 glitch
if JSON.const_defined?(:Pure)
  class JSON::Pure::Generator::State
    include ActiveSupport::CoreExtensions::Hash::Except
  end
end

About the Author

Biography

More Content by Alex Chaffee
Previous
Jasmine Presentation at Chicago’s BSCamp
Jasmine Presentation at Chicago’s BSCamp

Jasmine user Roy Kolak gave a presentation last night at BSCamp in Chicago. His slides are here As you ca...

Next
One team, one Tracker project
One team, one Tracker project

I often hear questions from Pivotal Tracker users about how to organize teams and projects. We also see man...