Class: Todo::Data::Matcher

Inherits:
Object
  • Object
show all
Includes:
Helpers::Hash::Slice
Defined in:
lib/todo/data/matcher.rb

Constant Summary collapse

ATTRS =
[:id, :text, :projects, :status, :after, :before]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Hash::Slice

#except, #slice

Constructor Details

#initialize(item, data) ⇒ Matcher

Returns a new instance of Matcher.



12
13
14
15
# File 'lib/todo/data/matcher.rb', line 12

def initialize(item, data)
  @item = item
  @data = slice(data, *ATTRS)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/todo/data/matcher.rb', line 10

def data
  @data
end

#itemObject (readonly)

Returns the value of attribute item.



10
11
12
# File 'lib/todo/data/matcher.rb', line 10

def item
  @item
end

Instance Method Details

#matches?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/todo/data/matcher.rb', line 17

def matches?
  return true if data.empty?
  data[:id] ? match_id : match_data
end