Class: DataMetaByteSer::RendCtx
- Inherits:
-
Object
- Object
- DataMetaByteSer::RendCtx
- Defined in:
- lib/dataMetaByteSer/util.rb
Overview
Rendering context with rendering-related properties and settings.
Instance Attribute Summary collapse
-
#baseName ⇒ Object
Base name of the type, without a namespace.
-
#fld ⇒ Object
Field currently on the context.
-
#imps ⇒ Object
Set of imports if any, each as symbol.
-
#model ⇒ Object
DataMeta DOM Model on the context.
-
#pckg ⇒ Object
Java package.
-
#rec ⇒ Object
Record currently worked on.
-
#refType ⇒ Object
The data type of the entity on the context.
Instance Method Summary collapse
-
#<<(import) ⇒ Object
Add an import to the context, returns self for call chaining.
-
#fType ⇒ Object
Effective field type.
-
#importsText ⇒ Object
Formats imports into Java source, sorted.
-
#init(model, rec, pckg, baseName) ⇒ Object
Initialize the context with the model, the record, the package and the basename.
-
#initialize ⇒ RendCtx
constructor
Creates a new context.
-
#isMapping ⇒ Object
Determines if the refType is a DataMetaDom::Mapping.
-
#rw ⇒ Object
Readwrap.
-
#valGetter ⇒ Object
Getter name for the current field, if the type is Mapping, includes
.getKey()
too.
Constructor Details
#initialize ⇒ RendCtx
Creates a new context.
66 |
# File 'lib/dataMetaByteSer/util.rb', line 66 def initialize; @imps = Set.new end |
Instance Attribute Details
#baseName ⇒ Object
Base name of the type, without a namespace.
53 54 55 |
# File 'lib/dataMetaByteSer/util.rb', line 53 def baseName @baseName end |
#fld ⇒ Object
Field currently on the context.
61 62 63 |
# File 'lib/dataMetaByteSer/util.rb', line 61 def fld @fld end |
#imps ⇒ Object
Set of imports if any, each as symbol.
44 45 46 |
# File 'lib/dataMetaByteSer/util.rb', line 44 def imps @imps end |
#model ⇒ Object
DataMeta DOM Model on the context.
35 36 37 |
# File 'lib/dataMetaByteSer/util.rb', line 35 def model @model end |
#pckg ⇒ Object
Java package.
49 50 51 |
# File 'lib/dataMetaByteSer/util.rb', line 49 def pckg @pckg end |
#rec ⇒ Object
Record currently worked on.
39 40 41 |
# File 'lib/dataMetaByteSer/util.rb', line 39 def rec @rec end |
#refType ⇒ Object
The data type of the entity on the context.
57 58 59 |
# File 'lib/dataMetaByteSer/util.rb', line 57 def refType @refType end |
Instance Method Details
#<<(import) ⇒ Object
Add an import to the context, returns self for call chaining.
82 83 84 85 |
# File 'lib/dataMetaByteSer/util.rb', line 82 def <<(import) @imps << import.to_sym if import self end |
#fType ⇒ Object
Effective field type
102 103 104 |
# File 'lib/dataMetaByteSer/util.rb', line 102 def fType isMapping ? @refType.fromT : @fld.dataType end |
#importsText ⇒ Object
Formats imports into Java source, sorted.
90 91 92 |
# File 'lib/dataMetaByteSer/util.rb', line 90 def importsText @imps.to_a.map{|k| "import #{k};"}.sort.join("\n") end |
#init(model, rec, pckg, baseName) ⇒ Object
Initialize the context with the model, the record, the package and the basename. Returns self for call chaining.
77 |
# File 'lib/dataMetaByteSer/util.rb', line 77 def init(model, rec, pckg, baseName); @model = model; @rec = rec; @pckg = pckg; @baseName = baseName; self end |
#isMapping ⇒ Object
Determines if the refType is a DataMetaDom::Mapping.
97 98 99 |
# File 'lib/dataMetaByteSer/util.rb', line 97 def isMapping @refType.kind_of?(DataMetaDom::Mapping) && !@refType.kind_of?(DataMetaDom::BitSet) end |
#rw ⇒ Object
Readwrap
107 108 109 |
# File 'lib/dataMetaByteSer/util.rb', line 107 def rw isMapping ? lambda{|t| "new #{condenseType(@fld.dataType.type, self)}(#{t})"} : lambda{|t| t} end |
#valGetter ⇒ Object
Getter name for the current field, if the type is Mapping, includes .getKey()
too.
114 115 116 |
# File 'lib/dataMetaByteSer/util.rb', line 114 def valGetter "#{DataMetaDom.getterName(@fld)}()" + ( isMapping ? '.getKey()' : '') end |