Sha256: 0c346d19e18f9748c8acae59126f5530674e2d1489454c6a544f713cf2a9b011

Contents?: true

Size: 711 Bytes

Versions: 6

Compression:

Stored size: 711 Bytes

Contents

module ActiveAdminAddons
  class EnumBuilder < CustomBuilder
    def render
      raise 'you need to install enumerize gem first' unless defined? Enumerize::Value
      raise 'you need to pass an enumerize attribute' unless data.is_a?('Enumerize::Value'.constantize)
      context.status_tag(data.text, data)
    end
  end

  module ::ActiveAdmin
    module Views
      class TableFor
        def tag_column(*args, &block)
          column(*args) { |model| EnumBuilder.render(self, model, *args, &block) }
        end
      end
      class AttributesTable
        def tag_row(*args, &block)
          row(*args) { |model| EnumBuilder.render(self, model, *args, &block) }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activeadmin_addons-0.2.7 lib/activeadmin_addons/addons/enum_tag.rb
activeadmin_addons-0.2.6 lib/activeadmin_addons/addons/enum_tag.rb
activeadmin_addons-0.2.5 lib/activeadmin_addons/addons/enum_tag.rb
activeadmin_addons-0.2.4 lib/activeadmin_addons/addons/enum_tag.rb
activeadmin_addons-0.2.3 lib/activeadmin_addons/addons/enum_tag.rb
activeadmin_addons-0.2.2 lib/activeadmin_addons/addons/enum_tag.rb