lib/timeframe.rb in timeframe-0.0.9 vs lib/timeframe.rb in timeframe-0.0.10
- old
+ new
@@ -1,13 +1,15 @@
require 'date'
require 'active_support/version'
%w{
+ active_support/core_ext/hash
active_support/core_ext/array/extract_options
active_support/core_ext/string/conversions
active_support/core_ext/date/conversions
active_support/core_ext/integer/time
active_support/core_ext/numeric/time
+ active_support/json
}.each do |active_support_3_requirement|
require active_support_3_requirement
end if ActiveSupport::VERSION::MAJOR == 3
# Encapsulates a timeframe between two dates. The dates provided to the class are always until the last date. That means
@@ -243,18 +245,16 @@
# Returns the same Timeframe, only a year earlier
def last_year
self.class.new((from - 1.year), (to - 1.year))
end
-
- # Just a string that can be processed by Timeframe.interval... identical to #to_param
- def to_json(*)
+
+ def as_json(*)
to_param
end
- # http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/
- # Not really interested in making a Hash representation.
- def as_json(*)
+ # overriding this so that as_json is not used
+ def to_json(*)
to_param
end
# URL-friendly like "2008-10-25/2009-11-12"
def to_param