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.


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

def initialize(name, options={})
  self.name = name
  self.sortable = options[:sortable]
  self.groupable = options[:groupable] || false
  if groupable == true
    self.groupable = name.to_s
  end
  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

#groupableObject

Returns the value of attribute groupable


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

def groupable
  @groupable
end

#nameObject

Returns the value of attribute name


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

def name
  @name
end

#sortableObject


57
58
59
# File 'app/models/query.rb', line 57

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


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

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

#css_classesObject


82
83
84
# File 'app/models/query.rb', line 82

def css_classes
  name
end

#frozen?Boolean

Returns:

  • (Boolean)

65
66
67
# File 'app/models/query.rb', line 65

def frozen?
  @frozen
end

#group_value(object) ⇒ Object

Returns the group that object belongs to when grouping query results


78
79
80
# File 'app/models/query.rb', line 78

def group_value(object)
  value(object)
end

#inline?Boolean

Returns:

  • (Boolean)

61
62
63
# File 'app/models/query.rb', line 61

def inline?
  @inline
end

#sortable?Boolean

Returns true if the column is sortable, otherwise false

Returns:

  • (Boolean)

53
54
55
# File 'app/models/query.rb', line 53

def sortable?
  !@sortable.nil?
end

#value(object) ⇒ Object


69
70
71
# File 'app/models/query.rb', line 69

def value(object)
  object.send name
end

#value_object(object) ⇒ Object


73
74
75
# File 'app/models/query.rb', line 73

def value_object(object)
  object.send name
end