Module: MegaScaffold::Helpers
- Defined in:
- lib/mega_scaffold/helpers.rb
Instance Method Summary collapse
- #mega_scaffold_field_name(field) ⇒ Object
- #mega_scaffold_parent_url ⇒ Object
- #mega_scaffold_value(record, field, type = :show) ⇒ Object
Instance Method Details
#mega_scaffold_field_name(field) ⇒ Object
14 15 16 |
# File 'lib/mega_scaffold/helpers.rb', line 14 def mega_scaffold_field_name(field) (field[:label].presence || field[:name]).to_s.titleize end |
#mega_scaffold_parent_url ⇒ Object
18 19 20 |
# File 'lib/mega_scaffold/helpers.rb', line 18 def mega_scaffold_parent_url [mega_scaffold.scope&.to_sym, @parent].reject(&:blank?) end |
#mega_scaffold_value(record, field, type = :show) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/mega_scaffold/helpers.rb', line 4 def mega_scaffold_value(record, field, type = :show) if field[:value].is_a?(Proc) field[:value].call record, self elsif field[:value].is_a?(Hash) field[:value][type].call record, self else record.send(field[:name]) end end |