Class: CrudComponents::LikeSpec::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/crud_components/like_spec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#columnObject

Returns the value of attribute column

Returns:

  • (Object)

    the current value of column



36
37
38
# File 'lib/crud_components/like_spec.rb', line 36

def column
  @column
end

#klassObject

Returns the value of attribute klass

Returns:

  • (Object)

    the current value of klass



36
37
38
# File 'lib/crud_components/like_spec.rb', line 36

def klass
  @klass
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



36
37
38
# File 'lib/crud_components/like_spec.rb', line 36

def path
  @path
end

Instance Method Details

#arel_condition(pattern) ⇒ Object

escape ‘' must be explicit: sanitize_sql_like escapes with a backslash, which is not the default LIKE escape char on SQLite.



39
40
41
# File 'lib/crud_components/like_spec.rb', line 39

def arel_condition(pattern)
  Arel::Table.new(klass.table_name)[column].matches(pattern, '\\')
end

#join_fragmentObject



43
44
45
46
47
# File 'lib/crud_components/like_spec.rb', line 43

def join_fragment
  return nil if path.empty?

  path.reverse.reduce(nil) { |inner, assoc| inner ? { assoc => inner } : assoc }
end