lib/locomotive/liquid/drops/content_types.rb
# Get the _id attribute of a object or a list of objects which
# can include String (needed to retrieve a model
# based on its permalink or its label field) or ContentEntry instances.
#
# @param [ Object ] field The custom field
# @param [ Object ] value An object (content entry or label) or a list of objects
#
Get the _id attribute of a object or a list of objects which
can include String (needed to retrieve a model
based on its permalink or its label field) or ContentEntry instances.
Get the _id attribute of a object or a list of objects which can include String ( needed to retrieve a model based on its permalink or its label field ) or ContentEntry instances .
def object_to_id(field, value)
          if value.respond_to?(:map)
            value.map { |el| self.object_to_id(field, el) }
          elsif value.respond_to?(:_id)
            value._id
          else
            model = Locomotive::ContentType.class_name_to_content_type(field.class_name, @content_type.site)
            model.entries.or({ _slug: value }, { model.label_field_name => value }).first.try(:_id)
          end
        end
def object_to_id ( field , value ) if value . respond_to? ( :map ) value . map { | el | self . object_to_id ( field , el ) } elsif value . respond_to? ( :_id ) value . _id else model = Locomotive :: ContentType . class_name_to_content_type ( field . class_name , @content_type . site ) model . entries . or ( { _slug : value } , { model . label_field_name => value } ) . first . try ( :_id ) end end
Get the _id attribute of a object or a list of objects which
can include String (needed to retrieve a model
based on its permalink or its label field) or ContentEntry instances.
Get the _id attribute of a object or a list of objects which can include String ( needed to retrieve a model based on its permalink or its label field ) or ContentEntry instances .
field
<not_specific>
value
<not_specific>
<not_specific>
value An object (content entry or label) or a list of objects
value An object ( content entry or label ) or a list of objects