Class: RubyRemoteConfig::FileRepository
- Inherits:
-
Object
- Object
- RubyRemoteConfig::FileRepository
- Includes:
- Repository
- Defined in:
- lib/file_repository.rb
Overview
FileRepository is a struct that implements the Repository interface for handling configuration data stored in a YAML file.
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Attributes included from Repository
Instance Method Summary collapse
-
#initialize(name:, path:) ⇒ FileRepository
constructor
A new instance of FileRepository.
-
#refresh ⇒ Object
Refresh reads the YAML file, unmarshal it into the data map.
Methods included from Repository
Constructor Details
#initialize(name:, path:) ⇒ FileRepository
Returns a new instance of FileRepository.
14 15 16 17 |
# File 'lib/file_repository.rb', line 14 def initialize(name:, path:) super(name: name) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/file_repository.rb', line 12 def path @path end |
Instance Method Details
#refresh ⇒ Object
Refresh reads the YAML file, unmarshal it into the data map.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/file_repository.rb', line 20 def refresh @lock.synchronize do # Read the YAML file data = File.read(@path) # Unmarshal the YAML data into the data map @data = YAML.safe_load(data) # Store the raw data of the YAML file @raw_data = data end end |