Class: CanTango::Filter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cantango/filter/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, list = nil) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/cantango/filter/base.rb', line 6

def initialize item, list = nil
  @item         = item.to_sym
  @include_list = list.map(&:to_sym) || []
end

Instance Attribute Details

#include_listObject (readonly)

Returns the value of attribute include_list.



4
5
6
# File 'lib/cantango/filter/base.rb', line 4

def include_list
  @include_list
end

#itemObject (readonly)

Returns the value of attribute item.



4
5
6
# File 'lib/cantango/filter/base.rb', line 4

def item
  @item
end

Instance Method Details

#excluded?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/cantango/filter/base.rb', line 26

def excluded?
  false
end

#in_include_list?Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/cantango/filter/base.rb', line 17

def in_include_list?
  return false if include_list.blank?
  include_list.include? item
end

#not_only?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/cantango/filter/base.rb', line 22

def not_only?
  false
end

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/cantango/filter/base.rb', line 11

def valid?
  return false if !in_include_list?
  return false if not_only?
  !excluded?
end