Class: Hyrax::Microdata
- Inherits:
-
Object
- Object
- Hyrax::Microdata
- Includes:
- Singleton
- Defined in:
- app/services/hyrax/microdata.rb
Overview
This was extracted from internationalization because Schema.org keys are not internationalized
Responsible for extracting information related to Schema.org microdata.
You may load more than one source file. Source files that are later in the load process will overlay files that are earlier.
Constant Summary collapse
Class Method Summary collapse
- .clear_load_paths! ⇒ Object private
- .fetch(key, default: nil) ⇒ Object
-
.load_paths ⇒ Array<String>
Allow clients to register paths providing config data sources.
-
.load_paths=(input) ⇒ Object
Sets the load_paths.
- .reload! ⇒ Object
Instance Method Summary collapse
- #fetch(key, default:) ⇒ Object private
- #reload! ⇒ Object private
Class Method Details
.clear_load_paths! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 |
# File 'app/services/hyrax/microdata.rb', line 54 def self.clear_load_paths! @load_paths = nil reload! end |
.fetch(key, default: nil) ⇒ Object
Should we make specific methods for fetching :property, :type, :value. This would mean privatizing the fetch method
22 23 24 |
# File 'app/services/hyrax/microdata.rb', line 22 def self.fetch(key, default: nil) instance.fetch(key, default: default) end |
.load_paths ⇒ Array<String>
The load paths will be processed and loaded into in the natural array order. As each file is loaded, it overlays the already registered keys.
Allow clients to register paths providing config data sources. Register a config files like this:
Microdata.load_path << 'path/to/locale/en.yml'
39 40 41 |
# File 'app/services/hyrax/microdata.rb', line 39 def self.load_paths @load_paths ||= [FILENAME] end |
.load_paths=(input) ⇒ Object
Sets the load_paths
48 49 50 51 |
# File 'app/services/hyrax/microdata.rb', line 48 def self.load_paths=(input) @load_paths = Array.wrap(input) reload! # If we are obliterating load paths, we really should clear data end |
.reload! ⇒ Object
60 61 62 |
# File 'app/services/hyrax/microdata.rb', line 60 def self.reload! instance.reload! end |
Instance Method Details
#fetch(key, default:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'app/services/hyrax/microdata.rb', line 27 def fetch(key, default:) data.fetch(key) { default } end |
#reload! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'app/services/hyrax/microdata.rb', line 65 def reload! @data = nil end |