Module: Protobuf::Mongoid::Fields::ClassMethods

Defined in:
lib/protobuf/mongoid/fields.rb

Overview

Class Methods

Instance Method Summary collapse

Instance Method Details

#_protobuf_date_datetime_time_or_timestamp_fieldObject



34
35
36
37
38
# File 'lib/protobuf/mongoid/fields.rb', line 34

def _protobuf_date_datetime_time_or_timestamp_field
  _protobuf_map_fields unless _protobuf_mapped_fields?

  @_protobuf_date_datetime_time_or_timestamp_field
end

#_protobuf_date_datetime_time_or_timestamp_field?(key) ⇒ Boolean

:nodoc:



46
47
48
# File 'lib/protobuf/mongoid/fields.rb', line 46

def _protobuf_date_datetime_time_or_timestamp_field?(key)
  _protobuf_date_datetime_time_or_timestamp_field.include?(key)
end

#_protobuf_date_field?(key) ⇒ Boolean

:nodoc:



41
42
43
# File 'lib/protobuf/mongoid/fields.rb', line 41

def _protobuf_date_field?(key)
  _protobuf_field_types[:date].include?(key)
end

#_protobuf_datetime_field?(key) ⇒ Boolean

:nodoc:



51
52
53
# File 'lib/protobuf/mongoid/fields.rb', line 51

def _protobuf_datetime_field?(key)
  _protobuf_field_types[:datetime].include?(key)
end

#_protobuf_field_typesObject



28
29
30
31
32
# File 'lib/protobuf/mongoid/fields.rb', line 28

def _protobuf_field_types
  _protobuf_map_fields unless _protobuf_mapped_fields?

  @_protobuf_field_types
end

#_protobuf_fieldsObject



22
23
24
25
26
# File 'lib/protobuf/mongoid/fields.rb', line 22

def _protobuf_fields
  _protobuf_map_fields unless _protobuf_mapped_fields?

  @_protobuf_fields
end

#_protobuf_map_fields(force = false) ⇒ Object

Map out the fields for future reference on type conversion :nodoc: TODO: Check if collection exists collection_exists? is not a Mongoid method. We need to check $exists? return unless collection_exists?



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/protobuf/mongoid/fields.rb', line 60

def _protobuf_map_fields(force = false)
  FIELD_TYPE_MAP_MUTEX.synchronize do
    @_protobuf_mapped_fields = false if force
    return if _protobuf_mapped_fields?

    initialize_protobuf_field_containers
    map_protobuf_fields

    @_protobuf_mapped_fields = true
  end
end

#_protobuf_mapped_fields?Boolean



72
73
74
# File 'lib/protobuf/mongoid/fields.rb', line 72

def _protobuf_mapped_fields?
  @_protobuf_mapped_fields
end

#_protobuf_time_field?(key) ⇒ Boolean

:nodoc:



77
78
79
# File 'lib/protobuf/mongoid/fields.rb', line 77

def _protobuf_time_field?(key)
  _protobuf_field_types[:time].include?(key)
end

#_protobuf_timestamp_field?(key) ⇒ Boolean

:nodoc:



82
83
84
# File 'lib/protobuf/mongoid/fields.rb', line 82

def _protobuf_timestamp_field?(key)
  _protobuf_field_types[:timestamp].include?(key)
end