Class: UIView

Inherits:
Object
  • Object
show all
Defined in:
lib/motion-xray/xray_ext.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.xrayObject

Returns the value of attribute xray



13
14
15
# File 'lib/motion-xray/xray_ext.rb', line 13

def xray
  @xray
end

Class Method Details

.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

Instance Method Details

#xrayObject



69
70
71
# File 'lib/motion-xray/xray_ext.rb', line 69

def xray
  self.class.build_xray
end

#xray_subviewsObject



73
74
75
# File 'lib/motion-xray/xray_ext.rb', line 73

def xray_subviews
  subviews
end