class ReportsKits::Reports::FilterTypes::Boolean

Constants

DEFAULT_CRITERIA

Public Instance Methods

apply_conditions(records) click to toggle source
# File lib/reports_kits/reports/filter_types/boolean.rb, line 9
def apply_conditions(records)
  case conditions
  when ::String
    records.where("(#{conditions}) #{sql_operator} true")
  when ::Hash
    boolean_value ? records.where(conditions) : records.not.where(conditions)
  when ::Proc
    conditions.call(records)
  else
    raise ArgumentError.new("Unsupported conditions type: '#{conditions}'")
  end
end
boolean_value() click to toggle source
# File lib/reports_kits/reports/filter_types/boolean.rb, line 22
def boolean_value
  case value
  when true, 'true'
    true
  when false, 'false'
    false
  else
    raise ArgumentError.new("Unsupported value: '#{value}'")
  end
end
conditions() click to toggle source
# File lib/reports_kits/reports/filter_types/boolean.rb, line 41
def conditions
  settings[:conditions] || Data::Utils.quote_column_name(properties[:key])
end
sql_operator() click to toggle source
# File lib/reports_kits/reports/filter_types/boolean.rb, line 33
def sql_operator
  boolean_value ? '=' : '!='
end
valid?() click to toggle source
# File lib/reports_kits/reports/filter_types/boolean.rb, line 37
def valid?
  value.present?
end