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



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

def column
  @column
end

#klassObject

Returns the value of attribute klass

Returns:

  • (Object)

    the current value of klass



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

def klass
  @klass
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



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

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.



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

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

#join_fragmentObject



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

def join_fragment
  return nil if path.empty?

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