module SexyScopes::ActiveRecord::ClassMethods
Public Instance Methods
attribute(name)
click to toggle source
Creates and extends an Arel
Attribute
representing the table’s column with the given name
.
@param [String, Symbol] name The attribute name
@note Please note that no exception is raised if no such column actually exists.
@example
where attribute(:score) > 1000
# File lib/sexy_scopes/active_record/class_methods.rb, line 14 def attribute(name) attribute = arel_table[name] SexyScopes.extend_expression(attribute) end
sql_literal(expression)
click to toggle source
Creates and extends an Arel
SqlLiteral
instance for the given expression
, first converted to a string using to_s
.
@param [String, to_s] expression Any SQL expression.
@example
where sql('LENGTH(email)') > 200
# File lib/sexy_scopes/active_record/class_methods.rb, line 27 def sql_literal(expression) ::Arel.sql(expression.to_s).tap do |literal| SexyScopes.extend_expression(literal) SexyScopes.extend_predicate(literal) end end
Also aliased as: sql