Module: CurationConcerns::CharacterizationBehavior
- Extended by:
- ActiveSupport::Concern
- Included in:
- FileSetPresenter
- Defined in:
- app/presenters/curation_concerns/characterization_behavior.rb
Instance Method Summary collapse
-
#additional_characterization_metadata ⇒ Object
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” }.
- #characterization_metadata ⇒ Object
- #characterized? ⇒ Boolean
- #label_for_term(term) ⇒ Object
-
#primary_characterization_values(term) ⇒ Array
Returns an array of characterization values truncated to 250 characters limited to the maximum number of configured values.
-
#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.
Instance Method Details
#additional_characterization_metadata ⇒ Object
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"
37 38 39 |
# File 'app/presenters/curation_concerns/characterization_behavior.rb', line 37 def @additional_characterization_metadata ||= {} end |
#characterization_metadata ⇒ Object
26 27 28 |
# File 'app/presenters/curation_concerns/characterization_behavior.rb', line 26 def @characterization_metadata ||= end |
#characterized? ⇒ Boolean
22 23 24 |
# File 'app/presenters/curation_concerns/characterization_behavior.rb', line 22 def characterized? !.values.compact.empty? end |
#label_for_term(term) ⇒ Object
41 42 43 |
# File 'app/presenters/curation_concerns/characterization_behavior.rb', line 41 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.
49 50 51 52 53 |
# File 'app/presenters/curation_concerns/characterization_behavior.rb', line 49 def primary_characterization_values(term) values = values_for(term) values.slice!(CurationConcerns.config., (values.length - CurationConcerns.config.)) 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.
59 60 61 62 63 64 |
# File 'app/presenters/curation_concerns/characterization_behavior.rb', line 59 def secondary_characterization_values(term) values = values_for(term) additional_values = values.slice(CurationConcerns.config., values.length - CurationConcerns.config.) return [] unless additional_values truncate_all(additional_values) end |