Class: Mybatis::Generate::GenerateContext

Inherits:
Object
  • Object
show all
Defined in:
lib/mybatis/util/context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGenerateContext

Returns a new instance of GenerateContext.



45
46
47
48
# File 'lib/mybatis/util/context.rb', line 45

def initialize
  self.package = ''
  self.attributes = []
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



25
26
27
# File 'lib/mybatis/util/context.rb', line 25

def attributes
  @attributes
end

#mapper_packageObject

Returns the value of attribute mapper_package.



22
23
24
# File 'lib/mybatis/util/context.rb', line 22

def mapper_package
  @mapper_package
end

#packageObject

Returns the value of attribute package.



21
22
23
# File 'lib/mybatis/util/context.rb', line 21

def package
  @package
end

#po_nameObject

Returns the value of attribute po_name.



23
24
25
# File 'lib/mybatis/util/context.rb', line 23

def po_name
  @po_name
end

#table_nameObject

Returns the value of attribute table_name.



24
25
26
# File 'lib/mybatis/util/context.rb', line 24

def table_name
  @table_name
end

Class Method Details

.instance_with_options(options) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mybatis/util/context.rb', line 28

def instance_with_options options
  #{"package"=>"package", "name"=>"Order", "tablename"=>"t_order", "list"=>["id", "order_no", "create_time"]}
  p options
  context = self.new
  context.package = options[:package]
  context.mapper_package = options[:mapper_package]
  context.po_name = options[:name].upcase_first
  context.table_name =
      options[:tablename] != '' ? options[:tablename] : "t#{context.po_name.replace_upcase_to_underline}"
  for str in options[:list]
    attr = Mybatis::Generate::Attribute.instance_with_options str
    context.attributes << attr
  end
  context
end

Instance Method Details

#join_package_and_po_nameObject



50
51
52
53
# File 'lib/mybatis/util/context.rb', line 50

def join_package_and_po_name
  return "#{self.package}.#{self.po_name}" if self.package
  "#{self.po_name}"
end