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

Returns a new instance of AbstractSelectRenderer.



43
44
45
# File 'lib/model_base/column_attribute.rb', line 43

def initialize(column_attr)
  @column_attr = column_attr
end

Instance Attribute Details

#column_attrObject (readonly)

Returns the value of attribute column_attr.



42
43
44
# File 'lib/model_base/column_attribute.rb', line 42

def column_attr
  @column_attr
end

Instance Method Details

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



47
48
49
50
51
52
53
54
55
56
# File 'lib/model_base/column_attribute.rb', line 47

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: !column_attr.required?)
  options_exp = {}.inspect
  r = render_core(form_name, target_name)
  r << ", #{options_exp}"
  r << ", #{html_exp}" unless html.empty?
  r
end