class Build::Environment::Constructor

Public Class Methods

new(environment, proxy = nil) click to toggle source
# File lib/build/environment/constructor.rb, line 49
def initialize(environment, proxy = nil)
        @environment = environment
        @proxy = proxy
end

Public Instance Methods

[](key) click to toggle source
# File lib/build/environment/constructor.rb, line 91
def [] key
        @environment[key]
end
append(name) click to toggle source
# File lib/build/environment/constructor.rb, line 115
def append(name)
        @environment[name] = Array(@environment[name])
        
        return name
end
default(name) click to toggle source
# File lib/build/environment/constructor.rb, line 103
def default(name)
        @environment[name] = Default.new(@environment[name])
        
        return name
end
define(klass, name, &block) click to toggle source
# File lib/build/environment/constructor.rb, line 121
def define(klass, name, &block)
        @environment[name] = Define.new(klass, &block)
        
        return name
end
hash(**options) click to toggle source
# File lib/build/environment/constructor.rb, line 99
def hash(**options)
        OpenStruct.new(options)
end
method_missing(name, *args, **options, &block) click to toggle source
Calls superclass method
# 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
                # This is a bit of a hack, but I'm not sure if there is a better way.
                if options.empty?
                        @proxy.send(name, *args, &block)
                else
                        @proxy.send(name, *args, **options, &block)
                end
        else
                super
        end
end
parent() click to toggle source
# File lib/build/environment/constructor.rb, line 95
def parent
        @environment.parent
end
replace(name) click to toggle source
# File lib/build/environment/constructor.rb, line 109
def replace(name)
        @environment[name] = Replace.new(@environment[name])
        
        return name
end
respond_to(*args) click to toggle source
Calls superclass method
# 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) click to toggle source
Calls superclass method
# 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