Sha256: efb795f7718b8c5b39cf16ad64e45898be54614b50a5ee952b5b038521891360

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

# This file must be loaded after the JSON gem and any other library that beats up the Time class.
class Time
  # This date format sorts lexicographically
  # and is compatible with Javascript's <tt>new Date(time_string)</tt> constructor.
  # Note this this format stores all dates in UTC so that collation 
  # order is preserved. (There's no longer a need to set <tt>ENV['TZ'] = 'UTC'</tt>
  # in your application.)

  def to_json(options = nil)
    u = self.utc
    %("#{u.strftime("%Y/%m/%d %H:%M:%S +0000")}")
  end

  # Decodes the JSON time format to a UTC time.
  # Based on Time.parse from ActiveSupport. ActiveSupport's version
  # is more complete, returning a time in your current timezone, 
  # rather than keeping the time in UTC. YMMV.
  # def self.parse string, fallback=nil
  #   d = DateTime.parse(string).new_offset
  #   self.utc(d.year, d.month, d.day, d.hour, d.min, d.sec)
  # rescue
  #   fallback
  # end
end

module RestClient
  def self.copy(url, headers={})
    Request.execute(:method => :copy,
      :url => url,
      :headers => headers)
  end
  
  def self.move(url, headers={})
    Request.execute(:method => :move,
    :url => url,
    :headers => headers)
  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
jchris-couchrest-0.12.4 lib/couchrest/monkeypatches.rb
jchris-couchrest-0.12.5 lib/couchrest/monkeypatches.rb
jchris-couchrest-0.12.6 lib/couchrest/monkeypatches.rb
jgre-couchrest-0.12.6 lib/couchrest/monkeypatches.rb
mattly-couchrest-0.12.2 lib/couchrest/monkeypatches.rb
mattly-couchrest-0.12.6 lib/couchrest/monkeypatches.rb
couchrest-0.12.4 lib/couchrest/monkeypatches.rb