class Ruby::Pomodoro::Tasks::Resource
Public Class Methods
all()
click to toggle source
# File lib/ruby/pomodoro/tasks/resource.rb, line 21 def all store.values end
create(attributes)
click to toggle source
# File lib/ruby/pomodoro/tasks/resource.rb, line 10 def create(attributes) id = store.size.next Entity.new(id: id, **attributes.slice(:name, :spent_time)).tap do |task| store[id] = task end end
delete_all()
click to toggle source
# File lib/ruby/pomodoro/tasks/resource.rb, line 25 def delete_all store.clear end
find(id)
click to toggle source
# File lib/ruby/pomodoro/tasks/resource.rb, line 17 def find(id) store[id] end
sum(attribute)
click to toggle source
# File lib/ruby/pomodoro/tasks/resource.rb, line 29 def sum(attribute) all.inject(0) { |sum, task| sum + task.public_send(attribute).to_i } end
Private Class Methods
store()
click to toggle source
# File lib/ruby/pomodoro/tasks/resource.rb, line 35 def store @store ||= {} end