Class: Edgarj::Drawer::ColumnInfo::Normal

Inherits:
Base
  • Object
show all
Defined in:
app/helpers/edgarj/drawer/base.rb

Overview

Direct Known Subclasses

BelongsTo

Instance Method Summary collapse

Methods inherited from Base

#column_header_label, #field

Constructor Details

#initialize(model, name) ⇒ Normal

Returns a new instance of Normal.

Parameters:

  • model (AR)
  • name (String)


98
99
100
101
102
# File 'app/helpers/edgarj/drawer/base.rb', line 98

def initialize(model, name)
  @model          = model
  @name           = name
  @ar_column_info = model.columns_hash[name]
end

Instance Method Details

#column_value(rec, drawer) ⇒ Object

draw rec.col other than ‘belongs_to’

INPUTS

rec

AR instance



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'app/helpers/edgarj/drawer/base.rb', line 117

def column_value(rec, drawer)
  if (enum = drawer.vc.get_enum(rec.class, @ar_column_info))
    drawer.vc.draw_column_enum(rec, @ar_column_info, enum)
  else
    case @ar_column_info.type
    when :datetime
      drawer.vc.datetime_fmt(rec.send(name))
    when :date
      drawer.vc.date_fmt(rec.send(name))
    when :integer
      rec.send(name).to_s
    when :boolean
      rec.send(name) ? '' : ''
    else
      # NOTE: rec.send(col.name) is not used since sssn.send(:data)
      # becomes hash rather than actual string-data so that following
      # split() fails for Hash.
      if str = rec.attributes[name]
        draw_trimmed_str(str)
      else
        ''
      end
    end
  end
end

#label(vc) ⇒ Object



104
105
106
# File 'app/helpers/edgarj/drawer/base.rb', line 104

def label(vc)
  vc.column_label(@name)
end

#nameObject

just for backward compatibility



155
156
157
# File 'app/helpers/edgarj/drawer/base.rb', line 155

def name
  @name
end

#sort_keyObject

return table_name + col.name for sort



109
110
111
# File 'app/helpers/edgarj/drawer/base.rb', line 109

def sort_key
  @model.table_name + '.' + @name
end

#tag_optionsObject



143
144
145
146
147
148
149
150
151
152
# File 'app/helpers/edgarj/drawer/base.rb', line 143

def tag_options
  case @ar_column_info.type
  when :integer
    {class: 'align_right'}
  when :boolean
    {class: 'align_center'}
  else
    {}
  end
end

#typeObject

just for backward compatibility



160
161
162
# File 'app/helpers/edgarj/drawer/base.rb', line 160

def type
  @ar_column_info.type
end