Module: SexyScopes::ActiveRecord::ClassMethods
- Defined in:
- lib/sexy_scopes/active_record/class_methods.rb
Instance Method Summary collapse
-
#attribute(name) ⇒ Object
Creates and extends an Arel
Attribute
representing the table’s column with the givenname
. -
#sql_literal(expression) ⇒ Object
(also: #sql)
Creates and extends an Arel
SqlLiteral
instance for the givenexpression
, first converted to a string usingto_s
.
Instance Method Details
#attribute(name) ⇒ Object
Note:
Please note that no exception is raised if no such column actually exists.
Creates and extends an Arel Attribute
representing the table’s column with the given name
.
14 15 16 17 |
# 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) ⇒ Object Also known as: sql
Creates and extends an Arel SqlLiteral
instance for the given expression
, first converted to a string using to_s
.
27 28 29 30 31 32 |
# 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 |