Module: Protobuf::ActiveRecord::Columns::ClassMethods
- Defined in:
- lib/protobuf/active_record/columns.rb
Instance Method Summary collapse
- #_protobuf_column_types ⇒ Object
- #_protobuf_columns ⇒ Object
-
#_protobuf_date_column?(key) ⇒ Boolean
:nodoc:.
- #_protobuf_date_datetime_time_or_timestamp_column ⇒ Object
-
#_protobuf_date_datetime_time_or_timestamp_column?(key) ⇒ Boolean
:nodoc:.
-
#_protobuf_datetime_column?(key) ⇒ Boolean
:nodoc:.
-
#_protobuf_map_columns(force = false) ⇒ Object
Map out the columns for future reference on type conversion :nodoc:.
- #_protobuf_mapped_columns? ⇒ Boolean
-
#_protobuf_time_column?(key) ⇒ Boolean
:nodoc:.
-
#_protobuf_timestamp_column?(key) ⇒ Boolean
:nodoc:.
Instance Method Details
#_protobuf_column_types ⇒ Object
27 28 29 30 31 |
# File 'lib/protobuf/active_record/columns.rb', line 27 def _protobuf_column_types _protobuf_map_columns unless _protobuf_mapped_columns? @_protobuf_column_types end |
#_protobuf_columns ⇒ Object
21 22 23 24 25 |
# File 'lib/protobuf/active_record/columns.rb', line 21 def _protobuf_columns _protobuf_map_columns unless _protobuf_mapped_columns? @_protobuf_columns end |
#_protobuf_date_column?(key) ⇒ Boolean
:nodoc:
40 41 42 |
# File 'lib/protobuf/active_record/columns.rb', line 40 def _protobuf_date_column?(key) _protobuf_column_types[:date].include?(key) end |
#_protobuf_date_datetime_time_or_timestamp_column ⇒ Object
33 34 35 36 37 |
# File 'lib/protobuf/active_record/columns.rb', line 33 def _protobuf_map_columns unless _protobuf_mapped_columns? end |
#_protobuf_date_datetime_time_or_timestamp_column?(key) ⇒ Boolean
:nodoc:
45 46 47 |
# File 'lib/protobuf/active_record/columns.rb', line 45 def (key) .include?(key) end |
#_protobuf_datetime_column?(key) ⇒ Boolean
:nodoc:
50 51 52 |
# File 'lib/protobuf/active_record/columns.rb', line 50 def _protobuf_datetime_column?(key) _protobuf_column_types[:datetime].include?(key) end |
#_protobuf_map_columns(force = false) ⇒ Object
Map out the columns for future reference on type conversion :nodoc:
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/protobuf/active_record/columns.rb', line 56 def _protobuf_map_columns(force = false) COLUMN_TYPE_MAP_MUTEX.synchronize do @_protobuf_mapped_columns = false if force return unless table_exists? return if _protobuf_mapped_columns? @_protobuf_columns = {} @_protobuf_column_types = ::Hash.new { |h, k| h[k] = ::Set.new } = ::Set.new columns.map do |column| column_name_symbol = column.name.to_sym column_type_symbol = column.type.to_sym @_protobuf_columns[column_name_symbol] = column @_protobuf_column_types[column_type_symbol] << column_name_symbol if DATE_OR_TIME_TYPES.include?(column_type_symbol) << column_name_symbol end end @_protobuf_mapped_columns = true end end |
#_protobuf_mapped_columns? ⇒ Boolean
82 83 84 |
# File 'lib/protobuf/active_record/columns.rb', line 82 def _protobuf_mapped_columns? @_protobuf_mapped_columns end |
#_protobuf_time_column?(key) ⇒ Boolean
:nodoc:
87 88 89 |
# File 'lib/protobuf/active_record/columns.rb', line 87 def _protobuf_time_column?(key) _protobuf_column_types[:time].include?(key) end |
#_protobuf_timestamp_column?(key) ⇒ Boolean
:nodoc:
92 93 94 |
# File 'lib/protobuf/active_record/columns.rb', line 92 def (key) _protobuf_column_types[:timestamp].include?(key) end |