Class: Teapot::Environment::Constructor

Inherits:
Object
  • Object
show all
Defined in:
lib/teapot/environment/constructor.rb

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Constructor

Returns a new instance of Constructor.



27
28
29
# File 'lib/teapot/environment/constructor.rb', line 27

def initialize(environment)
	@environment = environment
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, value = nil, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/teapot/environment/constructor.rb', line 31

def method_missing(name, value = nil, &block)
	if block_given?
		@environment[name] = block
	else
		@environment[name] = value
	end
		
	name
end

Instance Method Details

#[](key) ⇒ Object



41
42
43
# File 'lib/teapot/environment/constructor.rb', line 41

def [] key
	@environment[key]
end

#append(name) ⇒ Object



53
54
55
# File 'lib/teapot/environment/constructor.rb', line 53

def append(name)
	@environment[name] = Array(@environment[name])
end

#default(name) ⇒ Object



45
46
47
# File 'lib/teapot/environment/constructor.rb', line 45

def default(name)
	@environment[name] = Default.new(@environment[name])
end

#replace(name) ⇒ Object



49
50
51
# File 'lib/teapot/environment/constructor.rb', line 49

def replace(name)
	@environment[name] = Replace.new(@environment[name])
end