Module: Finders

Defined in:
lib/my_todo/modules/finders.rb

Instance Method Summary collapse

Instance Method Details

#all_itemsObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/my_todo/modules/finders.rb', line 10

def all_items
  @items = case options[:status]
          when 'all'
            Item.all
          when 'done'
            Item.where(done: true)
          else
            Item.where(done: false)
          end
end

#detailed_statusesObject



21
22
23
# File 'lib/my_todo/modules/finders.rb', line 21

def detailed_statuses
  @detailed_statuses ||= Item::DETAILED_STATUSES
end

#itemObject



2
3
4
# File 'lib/my_todo/modules/finders.rb', line 2

def item
  @item ||= Item.where(id: options[:id]).first
end

#item_notesObject



6
7
8
# File 'lib/my_todo/modules/finders.rb', line 6

def item_notes
  @item_notes ||= item.notes
end

#list_statusesObject



25
26
27
# File 'lib/my_todo/modules/finders.rb', line 25

def list_statuses
  detailed_statuses.each_with_index {|status, index| say "#{index}: #{status}"}
end