File: model_dumper.rb

package info (click to toggle)
ruby-rgen 0.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,428 kB
  • sloc: ruby: 11,344; xml: 1,368; yacc: 72; makefile: 10
file content (29 lines) | stat: -rw-r--r-- 551 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module RGen

module Util

module ModelDumper

	def dump(obj=nil)
		obj ||= self
		if obj.is_a?(Array)
			obj.collect {|o| dump(o)}.join("\n\n")
		elsif obj.class.respond_to?(:ecore)
			([obj.to_s] +
			obj.class.ecore.eAllStructuralFeatures.select{|f| !f.many}.collect { |a| 
				"   #{a} => #{obj.getGeneric(a.name)}"
			} +
			obj.class.ecore.eAllStructuralFeatures.select{|f| f.many}.collect { |a|
				"   #{a} => [ #{obj.getGeneric(a.name).join(', ')} ]"
			}).join("\n")
		else
			obj.to_s
		end
	end

end

end

end