Skip to content

Commit

Permalink
fixed the data_type(:all) bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Adkisson committed Apr 28, 2010
1 parent ce770f9 commit f3de811
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lib/modesty/experiment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ def data

def chooses(alt, options={})
if options.include? :for
#puts "registering a passed-in identity of #{options[:for].inspect}"
self.data.register!(alt, options[:for])
else
#puts "registering in chooses with Modesty.identity == #{Modesty.identity.inspect}"
self.data.register!(alt, Modesty.identity)
end
end
Expand Down
5 changes: 3 additions & 2 deletions lib/modesty/metric.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def parse_date_or_range(start=nil,fin=nil)
data_type_by_range = :"#{data_type}_by_range"
define_method(data_type) do |*dates|
date_or_range = parse_date_or_range(*dates)

if date_or_range.is_a? Range
if self.data_respond_to? data_type_by_range
self.data.send(data_type_by_range, date_or_range)
Expand All @@ -78,7 +79,7 @@ def parse_date_or_range(start=nil,fin=nil)
self.data.send(data_type, date)
end
end
elsif date_or_range.is_a? Date
elsif date_or_range.is_a?(Date) || date_or_range == :all
self.data.send(data_type, date_or_range)
end
end
Expand All @@ -97,7 +98,7 @@ def parse_date_or_range(start=nil,fin=nil)
self.data.send(data_type, sym, date)
end
end
else
elsif date_or_range.is_a?(Date) || date_or_range == :all
return self.data.send(data_type, sym, date_or_range)
end
end
Expand Down
2 changes: 2 additions & 0 deletions spec/metric_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,7 @@

m.distribution_by(:zings).should == {56=>{1=>1}, 97=>{7=>1, 4=>1}}
m.distribution.should == {1 => 1, 7 => 1, 4 => 1}

m.distribution(:all).should == {1 => 1, 7 => 1, 4 => 1}
end
end

0 comments on commit f3de811

Please sign in to comment.