Class: Mensa::Row
- Inherits:
-
Object
- Object
- Mensa::Row
- Defined in:
- app/tables/mensa/row.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#view_context ⇒ Object
readonly
Returns the value of attribute view_context.
Instance Method Summary collapse
-
#initialize(table, record) ⇒ Row
constructor
A new instance of Row.
- #link ⇒ Object
- #link_attributes ⇒ Object
- #value(column) ⇒ Object
Constructor Details
#initialize(table, record) ⇒ Row
Returns a new instance of Row.
7 8 9 10 |
# File 'app/tables/mensa/row.rb', line 7 def initialize(table, record) @table = table @record = record end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
5 6 7 |
# File 'app/tables/mensa/row.rb', line 5 def record @record end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
5 6 7 |
# File 'app/tables/mensa/row.rb', line 5 def table @table end |
#view_context ⇒ Object (readonly)
Returns the value of attribute view_context.
5 6 7 |
# File 'app/tables/mensa/row.rb', line 5 def view_context @view_context end |
Instance Method Details
#link ⇒ Object
32 33 34 |
# File 'app/tables/mensa/row.rb', line 32 def link table.original_view_context.instance_exec(record, &table.link) if table.link end |
#link_attributes ⇒ Object
26 27 28 29 30 |
# File 'app/tables/mensa/row.rb', line 26 def link_attributes return {} unless link { href: link, data: { controller: "satis-link", action: "click->satis-link#follow tap->satis-link#follow" } } end |
#value(column) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/tables/mensa/row.rb', line 12 def value(column) if column.attribute && record.respond_to?(column.attribute) record.public_send(column.attribute) elsif column.method && record.respond_to?(column.method) record.public_send(column.method) elsif record.respond_to?(column.name) record.public_send(column.name) elsif record.respond_to?(:[]) record[column.name] else "-" end end |