Class: RsyncDeploy::Config
- Inherits:
-
Object
- Object
- RsyncDeploy::Config
- Defined in:
- lib/rsync_deploy/config.rb
Defined Under Namespace
Classes: MissingConfigError
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(file) ⇒ Config
constructor
A new instance of Config.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
- #set(key, value) ⇒ Object
Constructor Details
#initialize(file) ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 13 14 |
# File 'lib/rsync_deploy/config.rb', line 7 def initialize(file) if File.exists? file @config = {} instance_eval File.read(file) else raise MissingConfigError, "Missing config file - #{file}" end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rsync_deploy/config.rb', line 20 def method_missing(method_sym, *arguments, &block) if @config.has_key?(method_sym) self.class.send(:define_method, method_sym) do @config[method_sym] end @config[method_sym] else super end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
3 4 5 |
# File 'lib/rsync_deploy/config.rb', line 3 def config @config end |
Instance Method Details
#set(key, value) ⇒ Object
16 17 18 |
# File 'lib/rsync_deploy/config.rb', line 16 def set(key, value) @config[key] = value end |