Class: CanTango::Filters::Filter

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

Direct Known Subclasses

RoleFilter, RoleGroupFilter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, list = nil) ⇒ Filter

Returns a new instance of Filter.



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

def initialize item, list = nil
  @item         = item.to_sym
  @include_list = list || []
end

Instance Attribute Details

#include_listObject (readonly)

Returns the value of attribute include_list.



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

def include_list
  @include_list
end

#itemObject (readonly)

Returns the value of attribute item.



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

def item
  @item
end

Instance Method Details

#excluded?Boolean

Returns:

  • (Boolean)


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

def excluded?
  false
end

#in_include_list?Boolean

Returns:

  • (Boolean)


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

def in_include_list?
  return true if include_list.empty?
  include_list.include? item
end

#not_only?Boolean

Returns:

  • (Boolean)


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

def not_only?
  false
end

#valid?Boolean

Returns:

  • (Boolean)


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

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