Sha256: 4764e60a772a8e5ec5e546a15c9e5e59fe747c7dac9bc945fa04c6d454b13b5b

Contents?: true

Size: 1.27 KB

Versions: 26

Compression:

Stored size: 1.27 KB

Contents

module ActiveFedora::RDF
  # Transient class that represents a field that we send to solr.
  # It might be possible for two properties to share a single field map entry if they use the same solr key.
  # @attribute [Symbol] type the data type hint for ActiveFedora::Indexing::FieldMapper
  # @attribute [Array] behaviors the indexing hints such as :stored_searchable or :symbol
  # @!attribute [w] values the raw values
  class FieldMapEntry
    attr_accessor :type, :behaviors
    attr_writer :values

    def initialize
      @behaviors = []
      @values = []
    end

    # Merges any existing values for solr fields with new, incoming values and ensures that resulting values are unique.
    # @param [Symbol] type the data type for the field such as :string, :date, :integer
    # @param [Array] behaviors FieldMapper's behaviors for indexing such as :stored_searchable, :symbol
    # @param [Array] new_values values to append into the existing solr field
    def merge!(type, behaviors, new_values)
      self.type ||= type
      self.behaviors += behaviors
      self.behaviors.uniq!
      self.values += new_values
    end

    # @return [Array] the actual values that get sent to solr
    def values
      @values.map do |value|
        ValueCaster.new(value).value
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
active-fedora-15.0.1 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-15.0.0 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-14.0.1 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-14.0.0 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.3.0 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-12.2.4 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.2.7 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.2.5 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.2.4 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-12.2.3 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.2.3 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.2.2 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.2.0 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.1.3 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-12.2.2 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-12.2.1 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-12.0.3 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.1.2 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.1.1 lib/active_fedora/rdf/field_map_entry.rb
active-fedora-13.1.0 lib/active_fedora/rdf/field_map_entry.rb