class ReportsKit::Reports::FilterTypes::Base
Attributes
primary_dimension[RW]
properties[RW]
settings[RW]
Public Class Methods
new(settings, properties, primary_dimension:)
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 7 def initialize(settings, properties, primary_dimension:) self.settings = settings || {} self.properties = properties self.primary_dimension = primary_dimension end
Public Instance Methods
apply_filter(records)
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 13 def apply_filter(records) return records unless valid? records = records.joins(joins) if joins.present? return records if value.blank? && !is_a?(FilterTypes::Boolean) apply_conditions(records) end
default_criteria()
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 20 def default_criteria self.class::DEFAULT_CRITERIA end
Private Instance Methods
apply_conditions(_records)
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 26 def apply_conditions(_records) raise NotImplementedError end
column()
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 42 def column settings[:column] || Data::Utils.quote_column_name(properties[:key]) end
criteria()
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 30 def criteria @criteria ||= default_criteria.merge(properties[:criteria]) end
joins()
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 38 def joins settings[:joins] end
value()
click to toggle source
# File lib/reports_kit/reports/filter_types/base.rb, line 34 def value criteria[:value] end