Module: ROM::SQL::AttributeAliasing Private

Included in:
Attribute
Defined in:
lib/rom/sql/attribute_aliasing.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#aliased(alias_name) ⇒ SQL::Attribute Also known as: as

Return a new attribute with an alias

Examples:

users[:id].aliased(:user_id)

Returns:



15
16
17
18
19
20
21
# File 'lib/rom/sql/attribute_aliasing.rb', line 15

def aliased(alias_name)
  new_name, new_alias_name = extract_alias_names(alias_name)

  super(new_alias_name).with(name: new_name).meta(
    sql_expr: alias_sql_expr(sql_expr, new_alias_name)
  )
end