File: proxy.rb

package info (click to toggle)
ruby-arbre 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 440 kB
  • sloc: ruby: 1,716; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 609 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true
module Arbre
  class Element
    class Proxy < BasicObject
      undef_method :==
      undef_method :equal?

      def initialize(element)
        @element = element
      end

      def respond_to?(method, include_all = false)
        if method.to_s == 'to_ary'
          false
        else
          super || @element.respond_to?(method, include_all)
        end
      end

      def method_missing(method, *args, &block)
        if method.to_s == 'to_ary'
          super
        else
          @element.__send__ method, *args, &block
        end
      end
    end
  end
end