diff options
| author | Jack Nagel | 2013-01-19 20:45:58 -0600 | 
|---|---|---|
| committer | Jack Nagel | 2013-01-21 17:24:11 -0600 | 
| commit | 8bb496febfec16a78336fc40eac81c758ac669c6 (patch) | |
| tree | ce2e8b764347032daaa9ad8437fe9bd152c40ceb /Library/Homebrew/build_environment.rb | |
| parent | cfdc7efef925411efad291be5c6739979682b3b3 (diff) | |
| download | homebrew-8bb496febfec16a78336fc40eac81c758ac669c6.tar.bz2 | |
Object#instance_exec for Ruby 1.8.6
Not thread safe! But I don't think we care.
We want to evaluate the env DSL block in the context of ENV for asthetic
reasons, but we also want access to methods on the requirement instance.
We can use #instance_exec to pass the requirement itself into the block:
  class Foo < Requirement
    env do |req|
      append 'PATH', req.some_path
    end
    def some_path
      which 'something'
    end
  end
Also add a simplified version of Object#instance_exec for Ruby 1.8.6.
Diffstat (limited to 'Library/Homebrew/build_environment.rb')
| -rw-r--r-- | Library/Homebrew/build_environment.rb | 4 | 
1 files changed, 2 insertions, 2 deletions
diff --git a/Library/Homebrew/build_environment.rb b/Library/Homebrew/build_environment.rb index 18876f954..60e099977 100644 --- a/Library/Homebrew/build_environment.rb +++ b/Library/Homebrew/build_environment.rb @@ -18,9 +18,9 @@ class BuildEnvironment      @settings.include? :userpaths    end -  def modify_build_environment +  def modify_build_environment(context=nil)      p = @settings.find { |s| Proc === s } -    ENV.instance_eval(&p) unless p.nil? +    ENV.instance_exec(context, &p) unless p.nil?    end    def _dump(*)  | 
