Class: Twterm::Repository::StatusRepository
Instance Method Summary
collapse
#initialize
Methods included from Publisher
#publish
Methods included from Utils
check_type
#after_create, #before_create, #initialize
Instance Method Details
#all ⇒ Object
8
9
10
|
# File 'lib/twterm/repository/status_repository.rb', line 8
def all
repository.values
end
|
#create(tweet, is_retweeted_status = false) ⇒ Object
12
13
14
15
|
# File 'lib/twterm/repository/status_repository.rb', line 12
def create(, = false)
create(., true) unless ..is_a?(::NullObject)
super
end
|
#delete(id) ⇒ Object
17
18
19
20
|
# File 'lib/twterm/repository/status_repository.rb', line 17
def delete(id)
@touched_at.delete(id)
repository.delete(id)
end
|
#expire(threshold) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/twterm/repository/status_repository.rb', line 34
def expire(threshold)
now = Time.now
ids = repository
.to_a
.sort_by { |_, status| status.created_at }
.reverse
.drop(keep_minimum)
.select { |id, _| !@touched_at[id] || @touched_at[id] + threshold < now }
ids.each { |id| publish(garbage_collection_event_class.new(id)) }
repository.delete_if { |id, _| ids.include?(id) }
end
|
#find(id) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/twterm/repository/status_repository.rb', line 22
def find(id)
status = super
touch(status.) if !status.nil? && status.
status
end
|
#find_replies_for(id) ⇒ Object
30
31
32
|
# File 'lib/twterm/repository/status_repository.rb', line 30
def find_replies_for(id)
repository.values.select { |s| s.in_reply_to_status_id == id }
end
|
#ids ⇒ Object
48
49
50
|
# File 'lib/twterm/repository/status_repository.rb', line 48
def ids
repository.keys
end
|