Module: Danger::Helpers::ArraySubclass

Includes:
Comparable
Included in:
FileList
Defined in:
lib/danger/helpers/array_subclass.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



18
19
20
21
22
# File 'lib/danger/helpers/array_subclass.rb', line 18

def method_missing(name, *args, &block)
  super unless __array__.respond_to?(name)

  respond_to_method(name, *args, &block)
end

Instance Method Details

#<=>(other) ⇒ Object



36
37
38
39
40
# File 'lib/danger/helpers/array_subclass.rb', line 36

def <=>(other)
  return unless other.kind_of?(self.class)

  __array__ <=> other.instance_variable_get(:@__array__)
end

#initialize(array) ⇒ Object



8
9
10
# File 'lib/danger/helpers/array_subclass.rb', line 8

def initialize(array)
  @__array__ = array
end

#kind_of?(compare_class) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/danger/helpers/array_subclass.rb', line 12

def kind_of?(compare_class)
  return true if compare_class == self.class

  dummy.kind_of?(compare_class)
end

#respond_to_missing?(name, include_all) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/danger/helpers/array_subclass.rb', line 24

def respond_to_missing?(name, include_all)
  __array__.respond_to?(name, include_all) || super
end

#to_aObject



28
29
30
# File 'lib/danger/helpers/array_subclass.rb', line 28

def to_a
  __array__
end

#to_aryObject



32
33
34
# File 'lib/danger/helpers/array_subclass.rb', line 32

def to_ary
  __array__
end