Class: Liquigen::TypeMap
- Inherits:
-
Object
- Object
- Liquigen::TypeMap
- Defined in:
- lib/liquigen/type_map.rb
Instance Attribute Summary collapse
-
#java_map ⇒ Object
Returns the value of attribute java_map.
-
#map ⇒ Object
Returns the value of attribute map.
-
#rails_type ⇒ Object
Returns the value of attribute rails_type.
-
#state_map ⇒ Object
Returns the value of attribute state_map.
Instance Method Summary collapse
- #db_type ⇒ Object
-
#initialize(type) ⇒ TypeMap
constructor
A new instance of TypeMap.
- #java_type ⇒ Object
- #set_map ⇒ Object
- #statement_type ⇒ Object
Constructor Details
#initialize(type) ⇒ TypeMap
Returns a new instance of TypeMap.
52 53 54 55 |
# File 'lib/liquigen/type_map.rb', line 52 def initialize(type) self.rails_type = type set_map end |
Instance Attribute Details
#java_map ⇒ Object
Returns the value of attribute java_map.
5 6 7 |
# File 'lib/liquigen/type_map.rb', line 5 def java_map @java_map end |
#map ⇒ Object
Returns the value of attribute map.
4 5 6 |
# File 'lib/liquigen/type_map.rb', line 4 def map @map end |
#rails_type ⇒ Object
Returns the value of attribute rails_type.
3 4 5 |
# File 'lib/liquigen/type_map.rb', line 3 def rails_type @rails_type end |
#state_map ⇒ Object
Returns the value of attribute state_map.
6 7 8 |
# File 'lib/liquigen/type_map.rb', line 6 def state_map @state_map end |
Instance Method Details
#db_type ⇒ Object
57 58 59 |
# File 'lib/liquigen/type_map.rb', line 57 def db_type map[rails_type.to_sym] end |
#java_type ⇒ Object
61 62 63 |
# File 'lib/liquigen/type_map.rb', line 61 def java_type java_map[rails_type.to_sym] end |
#set_map ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/liquigen/type_map.rb', line 8 def set_map # Only for mysql # http://blog.ifyouseewendy.com/blog/2015/08/10/data-types-in-rails/ self.map = { integer: 'bigint', long: 'bigint', string: 'varchar(255)', text: 'text', float: 'float', decimal: 'decimal', datetime: 'datetime', date: 'date', time: 'time', binary: 'blob', boolean: 'boolean' } self.java_map = { integer: 'Long', long: 'Long', string: 'String', text: 'String', float: 'Float', decimal: 'BigDecimal', datetime: 'Instant', date: 'LocalDateTime', time: 'LocalTime', binary: 'Object', boolean: 'boolean' } self.state_map = { integer: 'Number', long: 'Number', string: '', text: '', float: 'Number', decimal: 'Number', datetime: 'Datetime', binary: '', boolean: '' } end |
#statement_type ⇒ Object
65 66 67 |
# File 'lib/liquigen/type_map.rb', line 65 def statement_type state_map[rails_type.to_sym] end |