Class: Crowbar::Client::Config
- Inherits:
-
Object
- Object
- Crowbar::Client::Config
- Includes:
- Singleton
- Defined in:
- lib/crowbar/client/config.rb
Instance Attribute Summary collapse
Class Method Summary collapse
- .config ⇒ Object
- .configure(options) ⇒ Object
- .defaults ⇒ Object
- .method_missing(method, *arguments, &block) ⇒ Object
- .options ⇒ Object
- .respond_to?(method, include_private = false) ⇒ Boolean
- .values ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object
56 57 58 |
# File 'lib/crowbar/client/config.rb', line 56 def config @config ||= Hashie::Mash.new end |
#options ⇒ Object
52 53 54 |
# File 'lib/crowbar/client/config.rb', line 52 def @options ||= defaults end |
#values ⇒ Object
60 61 62 |
# File 'lib/crowbar/client/config.rb', line 60 def values @values ||= Hashie::Mash.new end |
Class Method Details
.config ⇒ Object
134 135 136 |
# File 'lib/crowbar/client/config.rb', line 134 def config instance.config end |
.configure(options) ⇒ Object
122 123 124 |
# File 'lib/crowbar/client/config.rb', line 122 def configure() instance.configure() end |
.defaults ⇒ Object
126 127 128 |
# File 'lib/crowbar/client/config.rb', line 126 def defaults instance.defaults end |
.method_missing(method, *arguments, &block) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/crowbar/client/config.rb', line 142 def method_missing(method, *arguments, &block) case when method.to_s.ends_with?("=") key = method.to_s.gsub(/=\z/, "") if values.key?(key) values[key] = arguments.first else super end when values.key?(method) values[method] else super end end |
.options ⇒ Object
130 131 132 |
# File 'lib/crowbar/client/config.rb', line 130 def instance. end |
.respond_to?(method, include_private = false) ⇒ Boolean
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/crowbar/client/config.rb', line 159 def respond_to?(method, include_private = false) case when method.to_s.ends_with?("=") key = method.to_s.gsub(/=\z/, "") if values.key?(key) true else super end when values.key?(method) true else super end end |
.values ⇒ Object
138 139 140 |
# File 'lib/crowbar/client/config.rb', line 138 def values instance.values end |
Instance Method Details
#configure(options) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/crowbar/client/config.rb', line 30 def configure() self. = Hashie::Mash.new( ) self.config = parser self.values = merge end |
#defaults ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/crowbar/client/config.rb', line 39 def defaults @defaults ||= Hashie::Mash.new( config: nil, alias: "default", username: "crowbar", password: "crowbar", server: "http://127.0.0.1:80", timeout: 60, anonymous: false, debug: false ) end |