Module: ProtocolBuffers::EnumClassMethods

Defined in:
lib/protocol_buffers/runtime/enum.rb

Instance Method Summary collapse

Instance Method Details

#fully_qualified_nameObject



13
14
15
# File 'lib/protocol_buffers/runtime/enum.rb', line 13

def fully_qualified_name
  @fully_qualified_name
end

#name_to_value_mapObject



28
29
30
31
32
33
34
# File 'lib/protocol_buffers/runtime/enum.rb', line 28

def name_to_value_map
  @name_to_value_map ||= self.constants.inject(Hash.new) do |hash, constant|
    hash[constant.to_sym] = self.const_get(constant)
    hash
  end
  @name_to_value_map
end

#set_fully_qualified_name(fully_qualified_name) ⇒ Object



9
10
11
# File 'lib/protocol_buffers/runtime/enum.rb', line 9

def set_fully_qualified_name(fully_qualified_name)
  @fully_qualified_name = fully_qualified_name.dup.freeze
end

#value_to_names_mapObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/protocol_buffers/runtime/enum.rb', line 17

def value_to_names_map
  @value_to_names_map ||= self.constants.inject(Hash.new) do |hash, constant|
    # values do not have to be unique
    value = self.const_get(constant)
    hash[value] ||= Array.new
    hash[value] << constant.to_sym
    hash
  end
  @value_to_names_map
end