Method: UIView.build_xray

Defined in:
lib/motion-xray/xray_ext.rb

.build_xrayObject

this could be optimized a tiny bit by only calling superclass.build_xray but i am le tired



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/motion-xray/xray_ext.rb', line 33

def build_xray
  @build_xray ||= begin
    retval = Hash.new { |hash,key| hash[key] = {} }
    klasses = []
    klass = self
    while klass && klass <= UIView
      klasses.unshift(klass)
      klass = klass.superclass
    end

    klasses.each do |klass|
      xray_props = klass.xray
      xray_props && xray_props.each do |key,values|
        values.keys.each do |check_unique|
          retval.each do |section, editors|
            editors.delete(check_unique)
          end
        end
        retval[key].merge!(values)
      end
    end

    # clean out nil-editors and empty sections
    retval.each do |section, editors|
      editors.each do |property, editor|
        editors.delete(property) unless editor
      end
      retval.delete(section) if editors.length == 0
    end

    retval
  end
end