Class: Hyphy::Filters::SQLFilter

Inherits:
AbstractFilter show all
Defined in:
lib/hyphy/filters/sql_filter.rb

Defined Under Namespace

Classes: IncorrectSQLTypeException

Instance Attribute Summary

Attributes inherited from AbstractFilter

#data

Instance Method Summary collapse

Constructor Details

#initialize(data, opts = {}) ⇒ SQLFilter

Returns a new instance of SQLFilter.



5
6
7
8
9
10
11
12
13
# File 'lib/hyphy/filters/sql_filter.rb', line 5

def initialize(data, opts={})
  @type = opts[:type] || :select

  unless [:select, :insert].include?(@type)
    raise IncorrectSQLTypeException, "incorrect type: #{@type}"
  end

  super
end

Instance Method Details

#filterObject



15
16
17
18
19
# File 'lib/hyphy/filters/sql_filter.rb', line 15

def filter
  @data.select! do |sql_statement|
    sql_statement.send("#{@type}?".to_sym)
  end
end