diff --git a/lib/redistat.rb b/lib/redistat.rb index 68ff931..4d52389 100644 --- a/lib/redistat.rb +++ b/lib/redistat.rb @@ -1,6 +1,7 @@ require 'rubygems' require 'active_support' +require 'active_support/hash_with_indifferent_access' if !Hash.respond_to?(:with_indifferent_access) # Active Support 2.x and 3.x require 'redis' require 'date' require 'time' diff --git a/lib/redistat/result.rb b/lib/redistat/result.rb index e433055..68dea24 100644 --- a/lib/redistat/result.rb +++ b/lib/redistat/result.rb @@ -1,5 +1,5 @@ module Redistat - class Result < ::Hash + class Result < ::ActiveSupport::HashWithIndifferentAccess attr_accessor :from attr_accessor :till diff --git a/spec/model_spec.rb b/spec/model_spec.rb index 87fbfdc..3894cf8 100644 --- a/spec/model_spec.rb +++ b/spec/model_spec.rb @@ -39,21 +39,21 @@ describe Redistat::Model do stats.first.should == stats.total stats = ModelHelper.fetch("sheep.black", 5.hours.ago, 1.hour.from_now) - stats.total["count"].should == 8 - stats.total["weight"].should == 617 + stats.total[:count].should == 8 + stats.total[:weight].should == 617 stats.first.should == stats.total ModelHelper.store("sheep.white", {:count => 5, :weight => 393}, 4.hours.ago) ModelHelper.store("sheep.white", {:count => 4, :weight => 316}) stats = ModelHelper.fetch("sheep.white", 2.hours.ago, 1.hour.from_now) - stats.total["count"].should == 4 - stats.total["weight"].should == 316 + stats.total[:count].should == 4 + stats.total[:weight].should == 316 stats.first.should == stats.total stats = ModelHelper.fetch("sheep.white", 5.hours.ago, 1.hour.from_now) - stats.total["count"].should == 9 - stats.total["weight"].should == 709 + stats.total[:count].should == 9 + stats.total[:weight].should == 709 stats.first.should == stats.total end