Class: ModelBase::ColumnAttribute::AbstractSelectRenderer
- Inherits:
-
Object
- Object
- ModelBase::ColumnAttribute::AbstractSelectRenderer
- Defined in:
- lib/model_base/column_attribute.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#column_attr ⇒ Object
readonly
Returns the value of attribute column_attr.
Instance Method Summary collapse
-
#initialize(column_attr) ⇒ AbstractSelectRenderer
constructor
A new instance of AbstractSelectRenderer.
- #render(form_name, target_name, options = {}) ⇒ Object
Constructor Details
#initialize(column_attr) ⇒ AbstractSelectRenderer
Returns a new instance of AbstractSelectRenderer.
156 157 158 |
# File 'lib/model_base/column_attribute.rb', line 156 def initialize(column_attr) @column_attr = column_attr end |
Instance Attribute Details
#column_attr ⇒ Object (readonly)
Returns the value of attribute column_attr.
155 156 157 |
# File 'lib/model_base/column_attribute.rb', line 155 def column_attr @column_attr end |
Instance Method Details
#render(form_name, target_name, options = {}) ⇒ Object
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/model_base/column_attribute.rb', line 160 def render(form_name, target_name, = {}) html = .delete(:html) || {} html_exp = html.empty? ? nil : html.inspect.gsub(/\A\{|\}\z/, '') .update(include_blank: true) if !column_attr.required? = '{%s}' % .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 |