Class: Social::Config::Driver::File
- Inherits:
-
Social::Config::Driver
- Object
- Social::Config::Driver
- Social::Config::Driver::File
- Defined in:
- lib/social/config/driver/file.rb
Instance Method Summary collapse
- #config_data ⇒ Object
- #config_file_path ⇒ Object
- #config_file_path=(new_path) ⇒ Object
- #config_root ⇒ Object
- #config_root=(new_root) ⇒ Object
-
#initialize(network_name) ⇒ File
constructor
A new instance of File.
- #load_config_file ⇒ Object
- #network_name ⇒ Object
Constructor Details
#initialize(network_name) ⇒ File
Returns a new instance of File.
4 5 6 7 |
# File 'lib/social/config/driver/file.rb', line 4 def initialize(network_name) @network_name = network_name @config_file_data = {} end |
Instance Method Details
#config_data ⇒ Object
13 14 15 |
# File 'lib/social/config/driver/file.rb', line 13 def config_data @config_data ||= load_config_file[@network_name] end |
#config_file_path ⇒ Object
32 33 34 35 |
# File 'lib/social/config/driver/file.rb', line 32 def config_file_path @config_file_path ||= ENV['SOCIAL_CONFIG_PATH'] @config_file_path ||= ::File.join(self.config_root, 'social.yml') end |
#config_file_path=(new_path) ⇒ Object
17 18 19 20 |
# File 'lib/social/config/driver/file.rb', line 17 def config_file_path=(new_path) @config_file_path = new_path @config = load_config_file if @config_data end |
#config_root ⇒ Object
26 27 28 29 30 |
# File 'lib/social/config/driver/file.rb', line 26 def config_root @config_root ||= ::File.join(Rails.root, 'config') if defined?(Rails) @config_root ||= ENV['SOCIAL_CONFIG_ROOT'] @config_root ||= ::File.join('.', 'config') end |
#config_root=(new_root) ⇒ Object
22 23 24 |
# File 'lib/social/config/driver/file.rb', line 22 def config_root=(new_root) @config_root = new_root end |
#load_config_file ⇒ Object
37 38 39 |
# File 'lib/social/config/driver/file.rb', line 37 def load_config_file @config_file_data[config_file_path] ||= YAML.load_file(config_file_path).with_indifferent_access end |
#network_name ⇒ Object
9 10 11 |
# File 'lib/social/config/driver/file.rb', line 9 def network_name @network_name end |