Mashify handling nested arrays of hashes properly #43

Merged
merged 1 commit into from Jun 24, 2012

Conversation

Projects
None yet
2 participants
Contributor

7even commented Jun 24, 2012

I changed FaradayMiddleware::Mashify#parse so it runs recursively after encountering an Array. So with the following connection:

connection = Faraday.new do |builder|
  builder.response :mashify
  builder.response :json

  builder.adapter :test do |stub|
    stub.get('/url') do
      data = [[{a: 1, b: 2}]]
      [200, {}, data.to_json]
    end
  end
end

we get a Hashie::Mash inside, not a Hash.

connection.get('/url').body
# => [[#<Hashie::Mash a=1 b=2>]]
Member

sferik commented Jun 24, 2012

Nice.

@sferik sferik added a commit that referenced this pull request Jun 24, 2012

@sferik sferik Merge pull request #43 from 7even/nested_mashing
Mashify handling nested arrays of hashes properly
477a622

@sferik sferik merged commit 477a622 into lostisland:master Jun 24, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment