Module: UnifiedPartialHelper

Defined in:
app/helpers/unified_partial_helper.rb

Instance Method Summary collapse

Instance Method Details

#attribute_display(object, attribute, options = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/unified_partial_helper.rb', line 2

def attribute_display(object, attribute, options={})
  with = options[:with] || :default
  attribute_value = object.send(attribute)
  layout = options[:layout] || "attribute_presentation/layout"
  locals = {
             object: object,
             attribute: attribute,
             value: attribute_value,
             label: attribute_label(attribute)
            }.merge(options.fetch(:locals, {}))
  unless options[:display_blank] || !attribute_value
    render partial: "attribute_presentation/#{with}",
           locals: locals,
           layout: layout
  end
end

#attribute_label(name, options = {}) ⇒ Object



19
20
21
22
# File 'app/helpers/unified_partial_helper.rb', line 19

def attribute_label(name, options = {})
  render partial: "attribute_presentation/label",
         locals:  {name: name}
end