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.
53 54 55 56 |
# File 'app/services/hyrax/microdata.rb', line 53 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
21 22 23 |
# File 'app/services/hyrax/microdata.rb', line 21 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'
38 39 40 |
# File 'app/services/hyrax/microdata.rb', line 38 def self.load_paths @load_paths ||= [FILENAME] end |
.load_paths=(input) ⇒ Object
Sets the load_paths
47 48 49 50 |
# File 'app/services/hyrax/microdata.rb', line 47 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
59 60 61 |
# File 'app/services/hyrax/microdata.rb', line 59 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.
26 27 28 |
# File 'app/services/hyrax/microdata.rb', line 26 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.
64 65 66 |
# File 'app/services/hyrax/microdata.rb', line 64 def reload! @data = nil end |