Class: Effective::ReportColumn

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/report_column.rb

Instance Method Summary collapse

Instance Method Details

#as_associated?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'app/models/effective/report_column.rb', line 60

def as_associated?
  [:belongs_to, :belongs_to_polymorphic, :has_many, :has_one].include?(as.to_sym)
end

#operation_labelObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/models/effective/report_column.rb', line 68

def operation_label
  return unless operation.present?

  case operation.to_sym
  when :eq then '='
  when :not_eq then '!='
  when :matches then '~='
  when :does_not_match then '!~='
  when :starts_with then 'starts with'
  when :ends_with then 'ends with'
  when :gt then '>'
  when :gteq then '>='
  when :lt then '<'
  when :lteq then '<='
  when :sql then 'sql'
  else
    raise("unexpected operation: #{operation}")
  end
end

#to_sObject



56
57
58
# File 'app/models/effective/report_column.rb', line 56

def to_s
  [name, operation_label, value].compact.join(' ').presence || 'report column'
end

#valueObject



64
65
66
# File 'app/models/effective/report_column.rb', line 64

def value
  value_date || value_decimal || value_integer || value_price || value_string.presence || value_associated.presence || value_boolean
end