module Recline

Constants

VERSION

Attributes

default_appearance_types[RW]
fallback_appearance[RW]
schema_name_prefix[RW]

Public Class Methods

appearance_for(field, klass, name) click to toggle source
# File lib/recline.rb, line 6
def self.appearance_for(field, klass, name)
  if field.metadata.key? :recline_appearance
    return field.metadata[:recline_appearance]
  else
    field_type = field.type
    while field_type.kind.wraps?
      field_type = field_type.of_type
    end

    if default_appearance_types.key? field_type
      default_appearance_types[field_type]
    else
      db_type = klass.type_for_attribute(name.to_s).type
      if default_appearance_types.key? db_type
        default_appearance_types[db_type]
      else
        fallback_appearance
      end
    end
  end
end