Sha256: 79fcb15dc1d9f16059d44a647b0df5a8caa408b6f4dede473bf1447c282677ac

Contents?: true

Size: 439 Bytes

Versions: 6

Compression:

Stored size: 439 Bytes

Contents

module Teacup
  module_function

  def to_instance(class_or_instance)
    if class_or_instance.is_a? Class
      unless class_or_instance <= UIView
        raise "Expected subclass of UIView, got: #{class_or_instance.inspect}"
      end
      return class_or_instance.new
    elsif class_or_instance.is_a?(UIView)
      return class_or_instance
    else
      raise "Expected a UIView, got: #{class_or_instance.inspect}"
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
teacup-1.3.4 lib/teacup/teacup_util.rb
teacup-1.3.3 lib/teacup/teacup_util.rb
teacup-1.3.2 lib/teacup/teacup_util.rb
teacup-1.3.1 lib/teacup/teacup_util.rb
teacup-1.3.0 lib/teacup/teacup_util.rb
teacup-1.2.9 lib/teacup/teacup_util.rb