Sha256: 8bc2fed9bd97040f21e45fdac6d492bfed0ffd2f06f6b1a3926bf7be87cc806c
Contents?: true
Size: 723 Bytes
Versions: 3
Compression:
Stored size: 723 Bytes
Contents
require 'ohm' module Tweetable class Persistable < Ohm::Model attribute :created_at attribute :updated_at def self.find_or_create(key, value) attributes = {key => value} # this persistable uses an old interface models = self.find(attributes) models.empty? ? self.create(attributes.merge(:created_at => Time.now.utc.to_s)) : models.first end def needs_update?(force = false) force or self.updated_at.blank? or (Time.parse(self.updated_at) + self.config[:update_delay]) < Time.now.utc end def client Tweetable.client end def config Tweetable.config end protected def validate end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tweetable-0.1.13 | lib/tweetable/persistable.rb |
tweetable-0.1.11 | lib/tweetable/persistable.rb |
tweetable-0.1.10 | lib/tweetable/persistable.rb |