Class: SnipSnip::Filter

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

Overview

Classes to filter out of the tracking when looking at which columns were selected.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filtered = []) ⇒ Filter

Returns a new instance of Filter.



9
10
11
12
13
14
15
# File 'lib/snip_snip/filter.rb', line 9

def initialize(filtered = [])
  @filtered = filtered

  return unless ActiveRecord.const_defined?(:InternalMetadata)

  @filtered << ActiveRecord::InternalMetadata
end

Instance Attribute Details

#filteredObject (readonly)

Returns the value of attribute filtered.



7
8
9
# File 'lib/snip_snip/filter.rb', line 7

def filtered
  @filtered
end

Class Method Details

.filtered?(record) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/snip_snip/filter.rb', line 21

def self.filtered?(record)
  (@instance ||= new).filtered?(record)
end

Instance Method Details

#filtered?(record) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/snip_snip/filter.rb', line 17

def filtered?(record)
  filtered.any? { |filter| record.is_a?(filter) }
end