Class: ActiveReporter::Dimension::Boolean

Inherits:
Category show all
Defined in:
lib/active_reporter/dimension/boolean.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #options, #report

Instance Method Summary collapse

Methods inherited from Category

#all_values, #filter, #group, #group_values

Methods inherited from Base

#attribute, #expression, #extract_sql_value, #filter, #filtering?, #group, #group_values, #grouping?, #initialize, #model, #null_order, #nulls_last?, #order, #order_expression, #params, #relate, #sort_desc?, #sort_order

Constructor Details

This class inherits a constructor from ActiveReporter::Dimension::Base

Instance Method Details

#filter_valuesObject

Cast incoming filter values (“true”/“1”/etc.) to real booleans so they match the column, preserving nil for IS NULL filtering.



8
9
10
# File 'lib/active_reporter/dimension/boolean.rb', line 8

def filter_values
  super.map { |value| cast_boolean(value) }.uniq
end

#sanitize_sql_value(value) ⇒ Object

Group/raw values come back adapter-specific (1/0 on SQLite and MySQL, true/false on PostgreSQL); normalize them to booleans (or nil).



14
15
16
# File 'lib/active_reporter/dimension/boolean.rb', line 14

def sanitize_sql_value(value)
  cast_boolean(value)
end