Class: FPM::Scriptable::EnvHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/scriptable/script.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missingObject



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/fpm/scriptable/script.rb', line 218

def handler(name, *opts)
  if !name.nil?
    name = name.to_s

    if name =~ /\=\z/
      name.gsub! /\=/, ''
      if opts.size == 1
        name.upcase!
        ENV[name] = opts.first
      end
    else
      if ENV.has_key? name
        ENV[name]
      else
        name.upcase!
        if ENV.has_key? name
          ENV[name]
        end
      end
    end
  end
end

Instance Method Details

#handler(name, *opts) ⇒ Object Also known as: method_missing



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/fpm/scriptable/script.rb', line 195

def handler(name, *opts)
  if !name.nil?
    name = name.to_s

    if name =~ /\=\z/
      name.gsub! /\=/, ''
      if opts.size == 1
        name.upcase!
        ENV[name] = opts.first
      end
    else
      if ENV.has_key? name
        ENV[name]
      else
        name.upcase!
        if ENV.has_key? name
          ENV[name]
        end
      end
    end
  end
end