Class: Build::Environment::Constructor
- Inherits:
-
Object
- Object
- Build::Environment::Constructor
show all
- Defined in:
- lib/build/environment/constructor.rb
Instance Method Summary
collapse
Constructor Details
#initialize(environment, proxy = nil) ⇒ Constructor
Returns a new instance of Constructor.
49
50
51
52
|
# File 'lib/build/environment/constructor.rb', line 49
def initialize(environment, proxy = nil)
@environment = environment
@proxy = proxy
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **options, &block) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/build/environment/constructor.rb', line 58
def method_missing(name, *args, **options, &block)
if options.empty?
if args.empty? and block_given?
@environment[name] = block
return name
elsif !args.empty?
if args.count == 1
@environment[name] = args.first
else
@environment[name] = args
end
return name
end
end
if @proxy
if options.empty?
@proxy.send(name, *args, &block)
else
@proxy.send(name, *args, **options, &block)
end
else
super
end
end
|
Instance Method Details
#[](key) ⇒ Object
91
92
93
|
# File 'lib/build/environment/constructor.rb', line 91
def [] key
@environment[key]
end
|
#append(name) ⇒ Object
115
116
117
118
119
|
# File 'lib/build/environment/constructor.rb', line 115
def append(name)
@environment[name] = Array(@environment[name])
return name
end
|
#default(name) ⇒ Object
103
104
105
106
107
|
# File 'lib/build/environment/constructor.rb', line 103
def default(name)
@environment[name] = Default.new(@environment[name])
return name
end
|
#define(klass, name, &block) ⇒ Object
121
122
123
124
125
|
# File 'lib/build/environment/constructor.rb', line 121
def define(klass, name, &block)
@environment[name] = Define.new(klass, &block)
return name
end
|
#hash(**options) ⇒ Object
99
100
101
|
# File 'lib/build/environment/constructor.rb', line 99
def hash(**options)
OpenStruct.new(options)
end
|
#parent ⇒ Object
95
96
97
|
# File 'lib/build/environment/constructor.rb', line 95
def parent
@environment.parent
end
|
#replace(name) ⇒ Object
109
110
111
112
113
|
# File 'lib/build/environment/constructor.rb', line 109
def replace(name)
@environment[name] = Replace.new(@environment[name])
return name
end
|
#respond_to(*args) ⇒ Object
87
88
89
|
# File 'lib/build/environment/constructor.rb', line 87
def respond_to(*args)
super or @proxy&.respond_to(*args)
end
|
#respond_to?(name, include_private = false) ⇒ Boolean
54
55
56
|
# File 'lib/build/environment/constructor.rb', line 54
def respond_to?(name, include_private = false)
@environment.include?(name) || @proxy&.respond_to?(name, include_private) || super
end
|