Class: ActiveRemote::Serializers::Protobuf::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/active_remote/serializers/protobuf.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, value) ⇒ Field

Constructor!



75
76
77
78
# File 'lib/active_remote/serializers/protobuf.rb', line 75

def initialize(field, value)
  @field = field
  @value = value
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



70
71
72
# File 'lib/active_remote/serializers/protobuf.rb', line 70

def field
  @field
end

#valueObject (readonly)

Returns the value of attribute value.



70
71
72
# File 'lib/active_remote/serializers/protobuf.rb', line 70

def value
  @value
end

Class Method Details

.from_attribute(field, value) ⇒ Object

Class methods



83
84
85
86
# File 'lib/active_remote/serializers/protobuf.rb', line 83

def self.from_attribute(field, value)
  field = self.new(field, value)
  field.from_attribute
end

Instance Method Details

#from_attributeObject

Instance methods



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/active_remote/serializers/protobuf.rb', line 91

def from_attribute
  case
  when field.repeated_message? then
    repeated_message_value
  when field.message? then
    message_value
  when field.repeated? then
    repeated_value.map { |value| typecast(value) }
  else
    typecasted_value
  end
end