Class: Tweetable::Persistable
- Inherits:
-
Ohm::Model
- Object
- Ohm::Model
- Tweetable::Persistable
show all
- Defined in:
- lib/tweetable/persistable.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_or_create(key, value) ⇒ Object
8
9
10
11
12
|
# File 'lib/tweetable/persistable.rb', line 8
def self.find_or_create(key, value)
attributes = {key => value} models = self.find(attributes)
models.empty? ? self.create(attributes.merge(:created_at => Time.now.utc.to_s)) : models.first
end
|
Instance Method Details
#client ⇒ Object
18
19
20
|
# File 'lib/tweetable/persistable.rb', line 18
def client
Tweetable.client
end
|
#config ⇒ Object
22
23
24
|
# File 'lib/tweetable/persistable.rb', line 22
def config
Tweetable.config
end
|
#needs_update?(force = false) ⇒ Boolean
14
15
16
|
# File 'lib/tweetable/persistable.rb', line 14
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
|