Class: Pragma::Filter::Like

Inherits:
Base
  • Object
show all
Defined in:
lib/pragma/filter/like.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#param

Instance Method Summary collapse

Constructor Details

#initialize(column:, **other) ⇒ Like

Returns a new instance of Like.



8
9
10
11
# File 'lib/pragma/filter/like.rb', line 8

def initialize(column:, **other)
  super(**other)
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



6
7
8
# File 'lib/pragma/filter/like.rb', line 6

def column
  @column
end

Instance Method Details

#apply(relation:, value:) ⇒ Object



13
14
15
# File 'lib/pragma/filter/like.rb', line 13

def apply(relation:, value:)
  relation.where("#{column} LIKE ?", "%#{value}%")
end