Sha256: b2376da8b1dc0428da2196e6eefe15f9ef1a2bd9876e3f306fe8bb75f79ffa6d
Contents?: true
Size: 1.26 KB
Versions: 18
Compression:
Stored size: 1.26 KB
Contents
# @provides MotionKit::BaseLayoutClassMethods module MotionKit module BaseLayoutClassMethods def target_klasses # We don't want subclasses, just BaseLayout return BaseLayout.target_klasses unless self == BaseLayout @target_klasses ||= {} end def targets(klass=nil) return nil if klass.nil? && self == BaseLayout return @targets || superclass.targets if klass.nil? @targets = klass if BaseLayout.target_klasses.key?(klass) && BaseLayout.target_klasses[klass] != self NSLog('WARNING! The class “%@” was registered with the layout class “%@”', klass, BaseLayout.target_klasses[klass]) end BaseLayout.target_klasses[klass] = self nil end # Instantiates a new Layout instance using `layout` as the root-level layout def layout_for(klass) memoized_klass = memoize(klass) memoized_klass && memoized_klass.new end # Cache registered classes def memoize(klass) @memoize ||= {} @memoize[klass] ||= begin while klass break if registered_class = target_klasses[klass] klass = klass.superclass end @memoize[klass] = registered_class if registered_class end @memoize[klass] end end end
Version data entries
18 entries across 18 versions & 1 rubygems