Class: ModelBase::ColumnAttribute::AbstractSelectRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/model_base/column_attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_attr) ⇒ AbstractSelectRenderer



152
153
154
# File 'lib/model_base/column_attribute.rb', line 152

def initialize(column_attr)
  @column_attr = column_attr
end

Instance Attribute Details

#column_attrObject (readonly)

Returns the value of attribute column_attr.



151
152
153
# File 'lib/model_base/column_attribute.rb', line 151

def column_attr
  @column_attr
end

Instance Method Details

#render(form_name, target_name, options = {}) ⇒ Object



156
157
158
159
160
161
162
163
164
165
# File 'lib/model_base/column_attribute.rb', line 156

def render(form_name, target_name, options = {})
  html = options.delete(:html) || {}
  html_exp = html.empty? ? nil : html.inspect.gsub(/\A\{|\}\z/, '')
  options.update(include_blank: true) if !column_attr.required?
  options_exp = '{%s}' % options.map{|k,v| "#{k}: #{v.inspect}"}.join(', ')
  r = render_core(form_name, target_name)
  r << ", #{options_exp}"
  r << ", #{html_exp}" unless html.empty?
  r
end