Sha256: 86997e86bfcb4ad1642cd839e93c517656347b3a910f234da099f51ade1bde7d

Contents?: true

Size: 708 Bytes

Versions: 22

Compression:

Stored size: 708 Bytes

Contents

module RestCore; end
class RestCore::Smash
  attr_accessor :data
  def initialize data
    self.data = data
  end

  def [] *keys
    keys.inject(data) do |r, k|
      if r.respond_to?(:key) && r.key?(k)
        r[k]
      elsif r.respond_to?(:[])
        r[k]
      else
        return nil # stop here
      end
    end
  end

  def == rhs
    if rhs.kind_of?(RestCore::Smash)
      data == rhs.data
    else
      data == rhs
    end
  end

  private
  def respond_to_missing? msg, include_private=false
    data.respond_to?(msg, include_private)
  end

  def method_missing msg, *args, &block
    if data.respond_to?(msg)
      data.public_send(msg, *args, &block)
    else
      super
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rest-core-4.0.1 lib/rest-core/util/smash.rb
rest-core-4.0.0 lib/rest-core/util/smash.rb
rest-core-3.6.0 lib/rest-core/util/smash.rb
rest-core-3.5.92 lib/rest-core/util/smash.rb
rest-core-3.5.91 lib/rest-core/util/smash.rb
rest-core-3.5.9 lib/rest-core/util/smash.rb
rest-core-3.5.8 lib/rest-core/util/smash.rb
rest-core-3.5.7 lib/rest-core/util/smash.rb
rest-core-3.5.6 lib/rest-core/util/smash.rb
rest-core-3.5.5 lib/rest-core/util/smash.rb
rest-core-3.5.4 lib/rest-core/util/smash.rb
rest-core-3.5.3 lib/rest-core/util/smash.rb
rest-core-3.5.2 lib/rest-core/util/smash.rb
rest-core-3.5.1 lib/rest-core/util/smash.rb
rest-core-3.5.0 lib/rest-core/util/smash.rb
rest-core-3.4.1 lib/rest-core/util/smash.rb
rest-core-3.4.0 lib/rest-core/util/smash.rb
rest-core-3.3.3 lib/rest-core/util/smash.rb
rest-core-3.3.2 lib/rest-core/util/smash.rb
rest-core-3.3.1 lib/rest-core/util/smash.rb