Sha256: 94032a87af8563bd0ffb8b9b2fb45b68e78d87edb7ec22ac733aa499929c6b24
Contents?: true
Size: 852 Bytes
Versions: 13
Compression:
Stored size: 852 Bytes
Contents
module Avo module Concerns module FindAssociationField # The supported association types are defined in the ASSOCIATIONS constant. unless defined?(ASSOCIATIONS) ASSOCIATIONS = ["belongs_to", "has_one", "has_many", "has_and_belongs_to_many", "array"] end # This method is used to find an association field for a given resource. # Ideally, the exact type of the association should be known in advance. # However, there are cases where the type is unknown # and the method will return the first matching association field # based on the provided association name. def find_association_field(resource:, association:) resource.get_field_definitions.find do |field| (field.id == association.to_sym) && field.type.in?(ASSOCIATIONS) end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems