Module: Filterable::AttributeNormalization

Defined in:
lib/filterable/attribute_normalization.rb

Overview

Shared by the datable/sortable declaration DSLs: a bare attribute maps onto its own column, a hash aliases public names to DB columns, anything else is ignored.

Class Method Summary collapse

Class Method Details

.normalize(attribute_name) ⇒ Hash

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

Normalizes a single attribute declaration into a public-name => column hash.

Parameters:

  • attribute_name (Symbol, String, Hash, Object)

    the raw declaration.

Returns:

  • (Hash)

    public name(s) mapped to DB column(s); empty for unsupported input.



15
16
17
18
19
20
21
# File 'lib/filterable/attribute_normalization.rb', line 15

def normalize(attribute_name)
  case attribute_name
  when Hash then attribute_name
  when String, Symbol then { attribute_name => attribute_name }
  else {}
  end
end