Sha256: 2fbe0961f1c1fc26486bf7c72f2075a86567a9096d58172192644632208144e5

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

def infer_type_from_attribute(resource_class, attribute)
  return :email if attribute == "email"
  return :url   if attribute == "url"

  resource_class.columns_hash[attribute].type
end

json.array! @resource_classes do |resource_class|
  json.menu_label resource_class.model_name.human(count: 2)
  json.singular resource_class.model_name.singular
  json.singular_human resource_class.model_name.human(count: 1)
  json.plural resource_class.model_name.plural
  json.plural_human resource_class.model_name.human(count: 2)

  attributes = resource_class.attribute_names.map do |attr|
    {
      key: attr,
      human: resource_class.human_attribute_name(attr),
      type: infer_type_from_attribute(resource_class, attr)
    }
  end
  json.attributes attributes
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hyper_admin-0.3.0 app/views/hyper_admin/resource_classes/index.json.jbuilder