Class: Chicago::Database::Filter Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column, value) ⇒ Filter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Filter.


39
40
41
42
# File 'lib/chicago/database/filter.rb', line 39

def initialize(column, value)
  @column = column
  @value = Filter.value_parser.new.parse(column, value)
end

Class Attribute Details

.value_parserObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


10
11
12
# File 'lib/chicago/database/filter.rb', line 10

def value_parser
  @value_parser
end

Instance Attribute Details

#columnObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

def column
  @column
end

#valueObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/chicago/database/filter.rb', line 14

def self.from_hash(hash)
  case hash[:op].to_sym
  when :eq
    EqualityFilter.new(hash[:column], hash[:value])
  when :lt
    ComparisonFilter.new(hash[:column], hash[:value], :<)
  when :lte
    ComparisonFilter.new(hash[:column], hash[:value], :<=)
  when :gt
    ComparisonFilter.new(hash[:column], hash[:value], :>)
  when :gte
    ComparisonFilter.new(hash[:column], hash[:value], :>=)
  when :ne
    NotFilter.new(EqualityFilter.new(hash[:column], hash[:value]))
  when :sw
    StartsWithFilter.new(hash[:column], hash[:value])
  when :nsw
    NotFilter.new(StartsWithFilter.new(hash[:column], hash[:value]))
  when :con
    ContainsFilter.new(hash[:column], hash[:value])
  when :ncon
    NotFilter.new(ContainsFilter.new(hash[:column], hash[:value]))
  end
end

Instance Method Details

#filter_dataset(dataset) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


44
45
46
# File 'lib/chicago/database/filter.rb', line 44

def filter_dataset(dataset)
  column.filter_dataset(dataset, to_sequel)
end