class Wallaby::ActiveRecord::ModelDecorator::TitleFieldFinder
Try to find the field that can be used as title
Constants
- TITLE_FIELD_TYPES
Public Class Methods
new(model_class, fields)
click to toggle source
@param model_class [Class] @param fields [Hash] fields metadata
# File lib/adapters/wallaby/active_record/model_decorator/title_field_finder.rb, line 12 def initialize(model_class, fields) @model_class = model_class @fields = fields end
Public Instance Methods
find()
click to toggle source
@return [String] field name that can be used as title
# File lib/adapters/wallaby/active_record/model_decorator/title_field_finder.rb, line 18 def find FieldUtils.first_field_by( { name: /title|name|label|string/, type: 'string' }, @fields ) || @model_class.primary_key end