Skip to content

Commit

Permalink
Moved from using Merb's core extensions' Hash#symbolize_keys! to Hash…
Browse files Browse the repository at this point in the history
…#to_mash to use the Mash library. This is because Hash#symbolize_keys! was removed from latest Merb (0.9.1) and is no longer supported (and was buggy, to begin with).
  • Loading branch information
mtodd committed Mar 7, 2008
1 parent 9610e2b commit f4a4449
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/halcyon
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ opts = OptionParser.new("", 24, ' ') do |opts|
ARGV.replace(conf.split)
opts.parse! ARGV
when Hash
conf.symbolize_keys!
conf.to_mash
options = options.merge(conf)
when Array
# TODO (MT) support multiple servers (or at least specifying which
Expand Down
6 changes: 3 additions & 3 deletions lib/halcyon/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def params
end

def post
@request.POST.symbolize_keys!
@request.POST.to_mash
end

def get
@request.GET.symbolize_keys!
@request.GET.to_mash
end

def query_params
@env['QUERY_STRING'].split(/&/).inject({}){|h,kp| k,v = kp.split(/=/); h[k] = v; h}.symbolize_keys!
@env['QUERY_STRING'].split(/&/).inject({}){|h,kp| k,v = kp.split(/=/); h[k] = v; h}.to_mash
end

def uri
Expand Down
4 changes: 2 additions & 2 deletions lib/halcyon/client/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def request(req, headers={})

# parse response
body = JSON.parse(res.body)
body.symbolize_keys!
body.to_mash

# handle non-successes
raise Halcyon::Client::Base::Exceptions.lookup(body[:status]).new unless res.kind_of? Net::HTTPSuccess
Expand All @@ -250,7 +250,7 @@ def request(req, headers={})
# format according to Net::HTTP for sending through as a Hash.
def format_body(data)
data = {:body => data} unless data.is_a? Hash
data.symbolize_keys!
data.to_mash
# uses the Merb Hash#to_params method defined in merb/core_ext.
data.to_params
end
Expand Down
6 changes: 3 additions & 3 deletions lib/halcyon/server/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def params
end

def query_params
@env['QUERY_STRING'].split(/&/).inject({}){|h,kp| k,v = kp.split(/=/); h[k] = v; h}.symbolize_keys!
@env['QUERY_STRING'].split(/&/).inject({}){|h,kp| k,v = kp.split(/=/); h[k] = v; h}.to_mash
end

def uri
Expand All @@ -219,11 +219,11 @@ def method
end

def post
@req.POST.symbolize_keys!
@req.POST.to_mash
end

def get
@req.GET.symbolize_keys!
@req.GET.to_mash
end

end
Expand Down
2 changes: 1 addition & 1 deletion spec/halcyon/router_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@app = Specr.new :port => 4000, :logger => Logger.new(StringIO.new(@log))
end

it "should prepares routes correctly when written correctly" do
it "should prepare routes correctly when written correctly" do
# routes have been defined for Specr
Halcyon::Application::Router.routes.should.not == []
Halcyon::Application::Router.routes.length.should > 0
Expand Down

0 comments on commit f4a4449

Please sign in to comment.