Class: Rubernate::ClassParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rubernate/class_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz, bytecode) ⇒ ClassParser

Returns a new instance of ClassParser.



7
8
9
10
11
12
13
# File 'lib/rubernate/class_parser.rb', line 7

def initialize(clazz,bytecode)
  puts "Class"
  self.clazz = clazz  
  self.bytecode = bytecode
  self.proxy_class = bytecode.create_class(name)      
  initialize_simples
end

Instance Attribute Details

#bytecodeObject

Returns the value of attribute bytecode.



5
6
7
# File 'lib/rubernate/class_parser.rb', line 5

def bytecode
  @bytecode
end

#clazzObject

Returns the value of attribute clazz.



5
6
7
# File 'lib/rubernate/class_parser.rb', line 5

def clazz
  @clazz
end

#proxy_classObject

Returns the value of attribute proxy_class.



5
6
7
# File 'lib/rubernate/class_parser.rb', line 5

def proxy_class
  @proxy_class
end

Instance Method Details

#build_id_for(field) ⇒ Object



27
28
29
# File 'lib/rubernate/class_parser.rb', line 27

def build_id_for(field)
  self.proxy_class.add_annotation field,"javax.persistence.Id"
end

#initialize_simplesObject

TODO need to correct this behaivor



16
17
18
19
20
21
22
23
24
25
# File 'lib/rubernate/class_parser.rb', line 16

def initialize_simples
  clazz.fields.each do |field|
    proxy_field = proxy_class.add_simple(field[:type],field[:name].to_s)
    field[:args].each do |f1|
      if f1.length > 0
        build_id_for proxy_field if f1[0][:id]
      end
    end
  end
end

#nameObject



33
34
35
# File 'lib/rubernate/class_parser.rb', line 33

def name
  self.clazz.name
end

#to_classObject



37
38
39
# File 'lib/rubernate/class_parser.rb', line 37

def to_class
  self.proxy_class.to_class
end