Class: QueryColumn

Inherits:
Object
  • Object
show all
Includes:
Redmine::I18n
Defined in:
app/models/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Redmine::I18n

#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages

Constructor Details

#initialize(name, options = {}) ⇒ QueryColumn

Returns a new instance of QueryColumn.


28
29
30
31
32
33
34
35
36
37
# File 'app/models/query.rb', line 28

def initialize(name, options={})
  self.name = name
  self.sortable = options[:sortable]
  self.groupable = options[:groupable] || false
  self.totalable = options[:totalable] || false
  self.default_order = options[:default_order]
  @inline = options.key?(:inline) ? options[:inline] : true
  @caption_key = options[:caption] || "field_#{name}".to_sym
  @frozen = options[:frozen]
end

Instance Attribute Details

#default_orderObject

Returns the value of attribute default_order


23
24
25
# File 'app/models/query.rb', line 23

def default_order
  @default_order
end

#groupable=(value) ⇒ Object (writeonly)

Sets the attribute groupable

Parameters:

  • value

    the value to set the attribute groupable to.


24
25
26
# File 'app/models/query.rb', line 24

def groupable=(value)
  @groupable = value
end

#nameObject

Returns the value of attribute name


23
24
25
# File 'app/models/query.rb', line 23

def name
  @name
end

#sortableObject


59
60
61
# File 'app/models/query.rb', line 59

def sortable
  @sortable.is_a?(Proc) ? @sortable.call : @sortable
end

#totalableObject

Returns the value of attribute totalable


23
24
25
# File 'app/models/query.rb', line 23

def totalable
  @totalable
end

Instance Method Details

#captionObject


39
40
41
42
43
44
45
46
47
48
# File 'app/models/query.rb', line 39

def caption
  case @caption_key
  when Symbol
    l(@caption_key)
  when Proc
    @caption_key.call
  else
    @caption_key
  end
end

#css_classesObject


84
85
86
# File 'app/models/query.rb', line 84

def css_classes
  name
end

#frozen?Boolean

Returns:

  • (Boolean)

67
68
69
# File 'app/models/query.rb', line 67

def frozen?
  @frozen
end

#group_by_statementObject


88
89
90
# File 'app/models/query.rb', line 88

def group_by_statement
  name.to_s
end

#group_value(object) ⇒ Object

Returns the group that object belongs to when grouping query results


80
81
82
# File 'app/models/query.rb', line 80

def group_value(object)
  value(object)
end

#groupable?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'app/models/query.rb', line 50

def groupable?
  @groupable
end

#inline?Boolean

Returns:

  • (Boolean)

63
64
65
# File 'app/models/query.rb', line 63

def inline?
  @inline
end

#sortable?Boolean

Returns true if the column is sortable, otherwise false

Returns:

  • (Boolean)

55
56
57
# File 'app/models/query.rb', line 55

def sortable?
  @sortable.present?
end

#value(object) ⇒ Object


71
72
73
# File 'app/models/query.rb', line 71

def value(object)
  object.send name
end

#value_object(object) ⇒ Object


75
76
77
# File 'app/models/query.rb', line 75

def value_object(object)
  object.send name
end