lib/teacup/layout.rb in teacup-0.3.10 vs lib/teacup/layout.rb in teacup-0.3.11
- old
+ new
@@ -70,21 +70,30 @@
properties = name_or_properties
elsif name_or_properties
name = name_or_properties.to_sym
end
+ # prevents the calling of restyle! until we return to this method
+ should_restyle = Teacup.should_restyle_and_block
+
view.stylesheet = stylesheet
view.stylename = name
- view.style(properties) if properties
+ if properties
+ view.style(properties) if properties
+ end
- begin
+ if block_given?
superview_chain << view
instance_exec(view, &block) if block_given?
- ensure
superview_chain.pop
end
+ if should_restyle
+ view.restyle!
+ # restore to whatever it was, either nil or true
+ Teacup.should_restyle!
+ end
view
end
# Add a new subview to the view heirarchy.
#
@@ -135,10 +144,10 @@
end
protected
def to_instance(class_or_instance)
- if Class === 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)