Sha256: b9d96663a0e5b586ddc3412eb77825200af3cb952f4fe0d6e926054c6b289c66

Contents?: true

Size: 809 Bytes

Versions: 5

Compression:

Stored size: 809 Bytes

Contents

class UIViewController

  def sugarcube_cleanup
    super
    self.view.sugarcube_cleanup
    self.childViewControllers.each do |subctlr|
      subctlr.sugarcube_cleanup
    end
  end

end


class UIResponder

  class << self

    def sugarcube_cleanup(&block)
      @sugarcube_cleanup ||= []
      return @sugarcube_cleanup unless block
      @sugarcube_cleanup << block
      return nil
    end

  end

  def sugarcube_cleanup
    self.class.ancestors.each do |klass|
      next unless klass.respond_to?(:sugarcube_cleanup)
      klass.sugarcube_cleanup.each do |block|
        self.instance_eval(&block)
      end
      break if klass == UIResponder
    end
  end

end


class UIView

  def sugarcube_cleanup
    super
    self.subviews.each do |subview|
      subview.sugarcube_cleanup
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sugarcube-1.3.7 lib/sugarcube/sugarcube_cleanup.rb
sugarcube-1.3.6 lib/sugarcube/sugarcube_cleanup.rb
sugarcube-1.3.5 lib/sugarcube/sugarcube_cleanup.rb
sugarcube-1.3.4 lib/sugarcube/sugarcube_cleanup.rb
sugarcube-1.3.3 lib/sugarcube/sugarcube_cleanup.rb