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!



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

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

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



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

def field
  @field
end

#valueObject (readonly)

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.from_attribute(field, value) ⇒ Object

Class methods



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

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

Instance Method Details

#from_attributeObject

Instance methods



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

def from_attribute
  if field.repeated_message?

    repeated_message_value
  elsif field.message?

    message_value
  elsif field.repeated?

    repeated_value.map { |value| cast(value) }
  else
    cast_value
  end
end