Sha256: f14b881695acc0c7c5c26571a3c2205281a137a584ec9ea304f3d16d52fe12a1
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
=begin rdoc To handle multiple GUI frameworks, Clevic makes use of Ruby's open classes. Whenever there is a class that interacts with a GUI framework (say Qt, or Java Swing) the framework-specific part of the class is loaded first to get access to the framework's inheritance hierarchy, then the file with the framework-neutral code is loaded. The code below helps to check that the relevant methods from framework-neutral code are already defined by the time the framework-neutral class definition is executed. =end class Class # method_name can be a symbol or a string. # # If a method of this name doesn't already exist # add it, so that if when it's called later it raises # and exception. Otherwise if the named method already # exists, just leave it alone. def framework_responsibility( method_name ) unless instance_methods.include?( method_name.to_s ) define_method method_name do raise "Framework-specific code has not defined for for #{self.class}##{method_name}" end end end def subclass_responsibility( method_name ) unless instance_methods.include?( method_name.to_s ) define_method( method_name ) do raise "#{method_name} is subclass responsibility for #{self.class}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clevic-0.13.0.b6 | lib/clevic/framework.rb |