Sha256: 6fd0a2860dfee2efaee7d56904a7180f3e4a9c972181025c21765058dc7b3c06

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

module Admin::Resources::DisplayHelper

  def build_display(item, fields)
    fields.map do |attribute, type|
      value = if (type == :boolean) || (data = item.send(attribute))
                send("display_#{type}", item, attribute)
              else
                "—".html_safe
              end

      [@resource.human_attribute_name(attribute), value]
    end
  end

  def typus_relationships
    String.new.tap do |html|
      @resource.typus_defaults_for(:relationships).each do |relationship|
        association = @resource.reflect_on_association(relationship.to_sym)
        next if association.macro == :belongs_to
        next if admin_user.cannot?('read', association.class_name.constantize)
        html << send("typus_form_#{association.macro}", relationship)
      end
    end.html_safe
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
typus-3.1.0.rc14 app/helpers/admin/resources/display_helper.rb
typus-3.1.0.rc13 app/helpers/admin/resources/display_helper.rb