Skip to content

Monkey Patching #to_hash before it's pulled

PikachuEXE edited this page Nov 16, 2012 · 2 revisions

Why

Pull request #44 & #25 are already created But it seems they are not pulled (or the owner is lazy) So you might want to use them before it's pulled

Code

(Code from #44)

# config/initializers/settings_logic.rb
### Monkey patch the gem so that it returns hash instead of it's own class
class Settingslogic
  # Returns an instance of a Hash object
  def to_hash
    Hash[self]
  end
end

I can also put the method inside the Settings or whatever class you use