diff options
| author | Mike McQuaid | 2016-09-24 20:48:03 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2016-09-24 20:48:03 +0100 | 
| commit | e767fd3df9d179fca0445cc0bc0fdc061ad857d6 (patch) | |
| tree | 93e9db33313b36eebe7d7fb3aedf0f92cc2c3918 /Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb | |
| parent | 7fc241765e3654718235791c32e5638bf7f8e15a (diff) | |
| parent | 232078df57418004bb9bf7abef877e734fcf7005 (diff) | |
| download | brew-e767fd3df9d179fca0445cc0bc0fdc061ad857d6.tar.bz2 | |
Merge branch 'master' into mkdir_with_intermediates
Diffstat (limited to 'Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb | 68 | 
1 files changed, 40 insertions, 28 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb b/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb index 02c76fb27..b1a850c5a 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl/stanza_proxy.rb @@ -1,37 +1,49 @@ -class Hbc::DSL::StanzaProxy -  attr_reader :type +module Hbc +  class DSL +    class StanzaProxy +      attr_reader :type -  def self.once(type) -    resolved = nil -    new(type) { resolved ||= yield } -  end +      def self.once(type) +        resolved = nil +        new(type) { resolved ||= yield } +      end -  def initialize(type, &resolver) -    @type = type -    @resolver = resolver -  end +      def initialize(type, &resolver) +        @type = type +        @resolver = resolver +      end -  def proxy? -    true -  end +      def proxy? +        true +      end -  def to_s -    @resolver.call.to_s -  end +      def to_s +        @resolver.call.to_s +      end -  # Serialization for dumpcask -  def encode_with(coder) -    coder["type"] = type -    coder["resolved"] = @resolver.call -  end +      # Serialization for dumpcask +      def encode_with(coder) +        coder["type"] = type +        coder["resolved"] = @resolver.call +      end -  def respond_to?(symbol, include_private = false) -    return true if %i{encode_with proxy? to_s type}.include?(symbol) -    return false if symbol == :to_ary -    @resolver.call.respond_to?(symbol, include_private) -  end +      def method_missing(method, *args) +        if method != :to_ary +          @resolver.call.send(method, *args) +        else +          super +        end +      end + +      def respond_to?(method, include_private = false) +        return true if %i{encode_with proxy? to_s type}.include?(method) +        return false if method == :to_ary +        @resolver.call.respond_to?(method, include_private) +      end -  def method_missing(symbol, *args) -    @resolver.call.send(symbol, *args) +      def respond_to_missing?(*) +        true +      end +    end    end  end  | 
