Class: Hyrax::M3ProfileEditor
- Inherits:
-
Object
- Object
- Hyrax::M3ProfileEditor
- Defined in:
- app/services/hyrax/m3_profile_editor.rb
Instance Attribute Summary collapse
-
#profile_path ⇒ Object
Returns the value of attribute profile_path.
Instance Method Summary collapse
- #find_i18n(label_value) ⇒ Object
-
#initialize(profile_path) ⇒ M3ProfileEditor
constructor
A new instance of M3ProfileEditor.
- #profile_data ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(profile_path) ⇒ M3ProfileEditor
Returns a new instance of M3ProfileEditor.
6 7 8 |
# File 'app/services/hyrax/m3_profile_editor.rb', line 6 def initialize(profile_path) @profile_path = profile_path end |
Instance Attribute Details
#profile_path ⇒ Object
Returns the value of attribute profile_path.
4 5 6 |
# File 'app/services/hyrax/m3_profile_editor.rb', line 4 def profile_path @profile_path end |
Instance Method Details
#find_i18n(label_value) ⇒ Object
21 22 23 24 25 |
# File 'app/services/hyrax/m3_profile_editor.rb', line 21 def find_i18n(label_value) I18n.reverse_lookup(label_value, scope: [:blacklight, :search, :fields, :show]) || I18n.reverse_lookup(label_value, scope: [:blacklight, :search, :fields, :index]) || label_value end |
#profile_data ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/services/hyrax/m3_profile_editor.rb', line 10 def profile_data return @profile_data if @profile_data # Use the provided path or default to the dassie m3_profile.yaml raise "Error: Profile file not found at #{profile_path}" unless File.exist?(profile_path) Rails.logger.debug "Processing M3 profile at: #{profile_path}" # Load the YAML file @profile_data = YAML.load_file(profile_path) end |
#save ⇒ Object
27 28 29 30 |
# File 'app/services/hyrax/m3_profile_editor.rb', line 27 def save File.write(@profile_path, profile_data.to_yaml) Rails.logger.debug "Updated profile saved to: #{@profile_path}" end |