1 # this class is incomplete, but will eventually be subclassable
4 SYM2ATTR = Hash.new { |h,k| h[k] = k.to_s.freeze } # :nodoc:
6 def self.subclass(name, type_db)
7 klass = Class.new(self)
8 klass.const_set :TYPE_DB, type_db
9 klass.const_set :NAME, name.to_s.dup.freeze
10 dump = type_db.to_hash
11 meta = dump[:MetaEventInfo] || []
12 methods = meta + dump[name.to_sym]
13 methods = methods.inject("") do |str, (k,_)|
14 str << "def #{k}; self[:#{k}]; end\n"
15 str << "def #{k}= val; self[:#{k}] = val; end\n"
17 klass.class_eval methods
23 if LWES::Event == klass
24 "#<#{klass}:#{to_hash.inspect}>"
26 "#<#{klass}(event:#{klass.const_get(:NAME)}):#{to_hash.inspect}>"
31 src.to_hash.each do |k,v|
41 alias_method :initialize_copy, :merge!