Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Properly implement to_hash #44

merged 1 commit into from

5 participants


Without this, calling to_hash always returned a SettingsLogic instance, which caused problems when calling methods such as #symbolize_keys on the resulting object.


There is also another pull request also for #to_hash: #25
Take a look


I prefer writing though :p

Edit: does not work >_<

@PikachuEXE PikachuEXE referenced this pull request

Implement #to_hash #25


cool! clear implementation :)


But still not pulled...


Can this please be merged already? I believe my pull request is clean, well tested and fixes a weird oddity. Seems pretty straight forward to me. Thanks!


The members of the organization seem not quite active...
At least on this project


umm, what's going on.
the last pull request merged is 2 months ago, so this request may be already seen by authers.

something problem? or what? please comment here...

@binarylogic binarylogic merged commit a905605 into binarylogic:master


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2012
  1. @cmer

    properly reimplement to_hash

    cmer authored
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 2 deletions.
  1. +5 −0 lib/settingslogic.rb
  2. +10 −2 spec/settingslogic_spec.rb
5 lib/settingslogic.rb
@@ -143,6 +143,11 @@ def []=(key,val)
create_accessor_for(key, val)
+ # Returns an instance of a Hash object
+ def to_hash
+ Hash[self]
+ end
# This handles naming collisions with Sinatra/Vlad/Capistrano. Since these use a set()
# helper that defines methods in Object, ANY method_missing ANYWHERE picks up the Vlad/Sinatra
# settings! So settings.deploy_to title actually calls Object.deploy_to (from set :deploy_to, "host"),
12 spec/settingslogic_spec.rb
@@ -162,5 +162,13 @@ class NoSource < Settingslogic; end
it "should be a hash" do
Settings.send(:instance).should be_is_a(Hash)
+ describe "#to_hash" do
+ it "should return a new instance of a Hash object" do
+ Settings.to_hash.should be_kind_of(Hash)
+ == "Hash"
+ Settings.to_hash.object_id.should_not == Settings.object_id
+ end
+ end
Something went wrong with that request. Please try again.