Module: LittleWeasel::Metadata::MetadataObserverable
- Includes:
- Metadatable
- Included in:
- InvalidWordsMetadata
- Defined in:
- lib/LittleWeasel/metadata/metadata_observerable.rb
Overview
Defines methods to support metadata modules that are observers of objects that include Metadata::DictionaryMetadata.
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary
Attributes included from Metadatable
Class Method Summary collapse
Instance Method Summary collapse
-
#actions_whitelist ⇒ Object
This method should return actions (messages) that can be sent to this object; for example, at a minimum :init and :refresh need to be in this list.
-
#observe? ⇒ Boolean
Return true/false depending on whether or not this metadata observer is in a state to observe.
-
#refresh_local_metadata ⇒ Object
This is an override of Metadata#refresh_local_metadata.
-
#update(_action, **_args) ⇒ Object
This method receives notifications from an observable.
Methods included from Metadatable
#init, #metadata_key, #refresh, #update_dictionary_metadata
Class Method Details
.included(base) ⇒ Object
13 14 15 |
# File 'lib/LittleWeasel/metadata/metadata_observerable.rb', line 13 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#actions_whitelist ⇒ Object
This method should return actions (messages) that can be sent to this object; for example, at a minimum :init and :refresh need to be in this list
85 86 87 |
# File 'lib/LittleWeasel/metadata/metadata_observerable.rb', line 85 def actions_whitelist %i[init refresh] end |
#observe? ⇒ Boolean
Return true/false depending on whether or not this metadata observer is in a state to observe.
(See .observe? class-level method comments)
52 53 54 |
# File 'lib/LittleWeasel/metadata/metadata_observerable.rb', line 52 def observe? self.class.observe? end |
#refresh_local_metadata ⇒ Object
This is an override of Metadata#refresh_local_metadata. See Metadata#refresh_local_metadata comments.
58 59 60 |
# File 'lib/LittleWeasel/metadata/metadata_observerable.rb', line 58 def @metadata = .(metadata_key: ) end |
#update(_action, **_args) ⇒ Object
This method receives notifications from an observable. object and should be chainable (return self). All actions should be filtered through the actions_whitelist and an error raised if action is not in the actions_whitelist. If **args are used, further filtering should be applied based on the need.
78 79 80 |
# File 'lib/LittleWeasel/metadata/metadata_observerable.rb', line 78 def update(_action, **_args) raise Errors::MustOverrideError end |