Class: HydraEditor::FieldMetadataService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hydra_editor/field_metadata_service.rb

Class Method Summary collapse

Class Method Details

.multiple?(model_class, field) ⇒ Boolean

If the field is a reflection, delegate to the reflection. If the field is a property, delegate to the property. Otherwise return false

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
# File 'app/services/hydra_editor/field_metadata_service.rb', line 6

def self.multiple?(model_class, field)
  if reflection = model_class.reflect_on_association(field)
    reflection.collection?
  elsif model_class.attribute_names.include?(field.to_s)
    model_class.multiple?(field)
  else
    false
  end
end