module LittleWeasel::Metadata::MetadataObserverable
Defines methods to support metadata modules that are observers of objects that include Metadata::DictionaryMetadata
.
Public Class Methods
# File lib/LittleWeasel/metadata/metadata_observerable.rb, line 13 def self.included(base) base.extend ClassMethods end
Public Instance Methods
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
# File lib/LittleWeasel/metadata/metadata_observerable.rb, line 85 def actions_whitelist %i[init refresh] end
Return true/false depending on whether or not this metadata observer is in a state to observe.
(See .observe? class-level method comments)
# File lib/LittleWeasel/metadata/metadata_observerable.rb, line 52 def observe? self.class.observe? end
This is an override of Metadata#refresh_local_metadata. See Metadata#refresh_local_metadata comments.
# File lib/LittleWeasel/metadata/metadata_observerable.rb, line 58 def refresh_local_metadata @metadata = dictionary_metadata_service.get_dictionary_metadata(metadata_key: metadata_key) end
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.
@example
def update(action, **args) raise ArgumentError unless actions_whitelist.include? action send(action) self end
# File lib/LittleWeasel/metadata/metadata_observerable.rb, line 78 def update(_action, **_args) raise Errors::MustOverrideError end