Sha256: 175d8cda17402044b3ab22148bf414752478cbff56f20004b3c5912a4488edc3

Contents?: true

Size: 786 Bytes

Versions: 44

Compression:

Stored size: 786 Bytes

Contents

module Radius
  class DelegatingOpenStruct # :nodoc:
    attr_accessor :object
    
    def initialize(object = nil)
      @object = object
      @hash = {}
    end

    def dup
      rv = self.class.new
      rv.instance_variable_set(:@hash, @hash.dup)
      rv
    end
    
    def method_missing(method, *args, &block)
      symbol = (method.to_s =~ /^(.*?)=$/) ? $1.intern : method
      if (0..1).include?(args.size)
        if args.size == 1
          @hash[symbol] = args.first
        else
          if @hash.has_key?(symbol)
            @hash[symbol]
          else
            unless object.nil?
              @object.send(method, *args, &block)
            else
              nil
            end
          end
        end
      else
        super
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 4 rubygems

Version Path
radius-0.7.5 lib/radius/delegating_open_struct.rb
depengine-0.0.31 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.24 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.21 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.20 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.19 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
radius-0.7.4 lib/radius/delegating_open_struct.rb
depengine-0.0.18 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.17 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/radius-0.6.1/lib/radius/delegating_open_struct.rb