Class: MagicScopes::StringScopesGenerator

Inherits:
MagicScopes::ScopesGenerator::Base show all
Includes:
EqualityScopes, OrderScopes
Defined in:
lib/magic_scopes/scopes_generators/string.rb

Instance Method Summary collapse

Methods included from OrderScopes

#by, #by_desc

Methods included from EqualityScopes

#eq, #ne, #with, #without

Methods inherited from MagicScopes::ScopesGenerator::Base

#initialize, instance

Constructor Details

This class inherits a constructor from MagicScopes::ScopesGenerator::Base

Instance Method Details

#ilike(name) ⇒ Object



15
16
17
# File 'lib/magic_scopes/scopes_generators/string.rb', line 15

def ilike(name)
  scope name || "#{@attr}_ilike", ilike_scope
end

#like(name) ⇒ Object



7
8
9
# File 'lib/magic_scopes/scopes_generators/string.rb', line 7

def like(name)
  scope name || "#{@attr}_like", ->(*vals) { where(build_query(*vals, "#{@key} LIKE ?", 'OR')) }
end

#not_ilike(name) ⇒ Object



19
20
21
# File 'lib/magic_scopes/scopes_generators/string.rb', line 19

def not_ilike(name)
  scope name || "#{@attr}_not_ilike", ilike_scope('NOT')
end

#not_like(name) ⇒ Object



11
12
13
# File 'lib/magic_scopes/scopes_generators/string.rb', line 11

def not_like(name)
  scope name || "#{@attr}_not_like", ->(*vals) { where(build_query(*vals, "#{@key} NOT LIKE ?", 'AND')) }
end