Module: Hyrax::CharacterizationBehavior

Extended by:
ActiveSupport::Concern
Included in:
FileSetPresenter
Defined in:
app/presenters/hyrax/characterization_behavior.rb

Instance Method Summary collapse

Instance Method Details

#additional_characterization_metadataObject

Override this if you want to inject additional characterization metadata Use a hash of key/value pairs where the value is an Array or String

term1: ["value"],
term2: ["value1", "value2"],
term3: "a string"


38
39
40
# File 'app/presenters/hyrax/characterization_behavior.rb', line 38

def 
  @additional_characterization_metadata ||= {}
end

#characterization_metadataObject


27
28
29
# File 'app/presenters/hyrax/characterization_behavior.rb', line 27

def 
  @characterization_metadata ||= 
end

#characterized?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'app/presenters/hyrax/characterization_behavior.rb', line 23

def characterized?
  !.values.compact.empty?
end

#label_for_term(term) ⇒ Object


42
43
44
# File 'app/presenters/hyrax/characterization_behavior.rb', line 42

def label_for_term(term)
  term.to_s.titleize
end

#primary_characterization_values(term) ⇒ Array

Returns an array of characterization values truncated to 250 characters limited to the maximum number of configured values.

Parameters:

  • term (Symbol)

    found in the characterization_metadata hash

Returns:

  • (Array)

    of truncated values


50
51
52
53
54
# File 'app/presenters/hyrax/characterization_behavior.rb', line 50

def primary_characterization_values(term)
  values = values_for(term)
  values.slice!(Hyrax.config.fits_message_length, (values.length - Hyrax.config.fits_message_length))
  truncate_all(values)
end

#secondary_characterization_values(term) ⇒ Array

Returns an array of characterization values truncated to 250 characters that are in excess of the maximum number of configured values.

Parameters:

  • term (Symbol)

    found in the characterization_metadata hash

Returns:

  • (Array)

    of truncated values


60
61
62
63
64
65
# File 'app/presenters/hyrax/characterization_behavior.rb', line 60

def secondary_characterization_values(term)
  values = values_for(term)
  additional_values = values.slice(Hyrax.config.fits_message_length, values.length - Hyrax.config.fits_message_length)
  return [] unless additional_values
  truncate_all(additional_values)
end