Module: Mode::Configurable
- Included in:
- Config, Mode::Connector::Config
- Defined in:
- lib/mode/configurable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
3 4 5 6 |
# File 'lib/mode/configurable.rb', line 3 def self.included(klass) klass.send :attr_reader, :path klass.send :extend, ClassMethods end |
Instance Method Details
#initialize(path, filename = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/mode/configurable.rb', line 30 def initialize(path, filename = nil) @path = self.class.full_path(path, filename) if File.exist?(@path) configure YAML.load_file(@path) else raise "Could not load configuration file from #{@path}" end end |
#save ⇒ Object
40 41 42 43 44 |
# File 'lib/mode/configurable.rb', line 40 def save File.open(path, 'w+') do |file| file.write(to_yaml) end end |