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_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
24 25 26 27 28 |
# File 'lib/protobuf/active_record/columns.rb', line 24 def _protobuf_column_types _protobuf_map_columns unless _protobuf_mapped_columns? @_protobuf_column_types end |
#_protobuf_columns ⇒ Object
18 19 20 21 22 |
# File 'lib/protobuf/active_record/columns.rb', line 18 def _protobuf_columns _protobuf_map_columns unless _protobuf_mapped_columns? @_protobuf_columns end |
#_protobuf_date_column?(key) ⇒ Boolean
:nodoc:
31 32 33 |
# File 'lib/protobuf/active_record/columns.rb', line 31 def _protobuf_date_column?(key) _protobuf_column_types.fetch(:date, false) && _protobuf_column_types[:date].include?(key) end |
#_protobuf_datetime_column?(key) ⇒ Boolean
:nodoc:
36 37 38 |
# File 'lib/protobuf/active_record/columns.rb', line 36 def _protobuf_datetime_column?(key) _protobuf_column_types.fetch(:datetime, false) && _protobuf_column_types[:datetime].include?(key) end |
#_protobuf_map_columns(force = false) ⇒ Object
Map out the columns for future reference on type conversion :nodoc:
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/protobuf/active_record/columns.rb', line 42 def _protobuf_map_columns(force = false) ::Thread.exclusive 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 } columns.map do |column| @_protobuf_columns[column.name.to_sym] = column @_protobuf_column_types[column.type.to_sym] << column.name.to_sym end @_protobuf_mapped_columns = true end end |
#_protobuf_mapped_columns? ⇒ Boolean
61 62 63 |
# File 'lib/protobuf/active_record/columns.rb', line 61 def _protobuf_mapped_columns? @_protobuf_mapped_columns end |
#_protobuf_time_column?(key) ⇒ Boolean
:nodoc:
66 67 68 |
# File 'lib/protobuf/active_record/columns.rb', line 66 def _protobuf_time_column?(key) _protobuf_column_types.fetch(:time, false) && _protobuf_column_types[:time].include?(key) end |
#_protobuf_timestamp_column?(key) ⇒ Boolean
:nodoc:
71 72 73 |
# File 'lib/protobuf/active_record/columns.rb', line 71 def (key) _protobuf_column_types.fetch(:timestamp, false) && _protobuf_column_types[:timestamp].include?(key) end |