Sha256: f53f8c1407035b575724321960df29f7500d427512623530bd733f49ef0de80f
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
module ByStar module ByDirection def before(*args) options = args.extract_options!.symbolize_keys! time = args.first || Time.zone.now send("before_#{time_klass(time)}", time, options) end alias_method :before_now, :before def after(*args) options = args.extract_options!.symbolize_keys! time = args.first || Time.zone.now send("after_#{time_klass(time)}", time, options) end alias_method :after_now, :after private def before_Time_or_Date(time_or_date, options={}) field = options[:field] || by_star_field where("#{field} <= ?", time_or_date) end alias_method :before_Time, :before_Time_or_Date alias_method :before_Date, :before_Time_or_Date def before_String(string, options={}) field = options[:field] || by_star_field if time = Chronic.parse(string) where("#{field} <= ?", time) else raise ParseError, "Chronic couldn't understand #{string.inspect}. Please try something else." end end def after_Time_or_Date(time_or_date, options={}) field = options[:field] || by_star_field where("#{field} >= ?", time_or_date) end alias_method :after_Time, :after_Time_or_Date alias_method :after_Date, :after_Time_or_Date def after_String(string, options={}) field = options[:field] || by_star_field if time = Chronic.parse(string) where("#{field} >= ?", time) else raise ParseError, "Chronic couldn't understand #{string.inspect}. Please try something else." end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
by_star-2.1.0.beta2 | lib/by_star/by_direction.rb |
by_star-2.0.0.beta1 | lib/by_star/by_direction.rb |