Class: Effective::TableRow
- Inherits:
-
Object
- Object
- Effective::TableRow
- Defined in:
- app/models/effective/table_row.rb
Direct Known Subclasses
Effective::TableRows::BelongsTo, Effective::TableRows::Boolean, Effective::TableRows::Collection, Effective::TableRows::ContentFor, Effective::TableRows::EffectiveAddress, Effective::TableRows::EmailField, Effective::TableRows::FileField, Effective::TableRows::PercentField, Effective::TableRows::PriceField, Effective::TableRows::TextArea, Effective::TableRows::UrlField
Instance Attribute Summary collapse
-
#builder ⇒ Object
Returns the value of attribute builder.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#content ⇒ Object
Intended for override.
- #controller_namespace ⇒ Object
-
#initialize(name, options, builder:) ⇒ TableRow
constructor
So this takes in the options for an entire form group.
-
#label ⇒ Object
Humanized label or the label from form.
-
#to_html(&block) ⇒ Object
Render method.
-
#value ⇒ Object
Value from resource.
Constructor Details
#initialize(name, options, builder:) ⇒ TableRow
So this takes in the options for an entire form group.
11 12 13 14 15 16 17 |
# File 'app/models/effective/table_row.rb', line 11 def initialize(name, , builder:) @builder = builder @template = builder.template @name = name @options = end |
Instance Attribute Details
#builder ⇒ Object
Returns the value of attribute builder.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def builder @builder end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def @options end |
#template ⇒ Object
Returns the value of attribute template.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def template @template end |
Instance Method Details
#content ⇒ Object
Intended for override
24 25 26 |
# File 'app/models/effective/table_row.rb', line 24 def content value end |
#controller_namespace ⇒ Object
19 20 21 |
# File 'app/models/effective/table_row.rb', line 19 def controller_namespace Effective::Resource.new(template.controller.controller_path).namespace end |
#label ⇒ Object
Humanized label or the label from form
36 37 38 39 40 41 |
# File 'app/models/effective/table_row.rb', line 36 def label text = [:label] || builder.human_attribute_name(name) prefix = builder.[:prefix] [*prefix, text].join(': ') end |
#to_html(&block) ⇒ Object
Render method
29 30 31 32 33 |
# File 'app/models/effective/table_row.rb', line 29 def to_html(&block) content_tag(:tr) do content_tag(:td, label) + content_tag(:td, content.presence || '-') end end |
#value ⇒ Object
Value from resource
44 45 46 |
# File 'app/models/effective/table_row.rb', line 44 def value [:value] || builder.value(name) end |