Class: ActiveRemote::Serializers::Protobuf::Fields
- Inherits:
-
Object
- Object
- ActiveRemote::Serializers::Protobuf::Fields
- Defined in:
- lib/active_remote/serializers/protobuf.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#message_class ⇒ Object
readonly
Returns the value of attribute message_class.
Class Method Summary collapse
-
.from_attributes(message_class, attributes) ⇒ Object
Class methods.
Instance Method Summary collapse
-
#from_attributes ⇒ Object
Instance methods.
-
#initialize(message_class, attributes = {}) ⇒ Fields
constructor
Constructor!.
Constructor Details
#initialize(message_class, attributes = {}) ⇒ Fields
Constructor!
44 45 46 47 |
# File 'lib/active_remote/serializers/protobuf.rb', line 44 def initialize(, attributes = {}) @attributes = attributes @message_class = end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
39 40 41 |
# File 'lib/active_remote/serializers/protobuf.rb', line 39 def attributes @attributes end |
#message_class ⇒ Object (readonly)
Returns the value of attribute message_class.
39 40 41 |
# File 'lib/active_remote/serializers/protobuf.rb', line 39 def @message_class end |
Class Method Details
.from_attributes(message_class, attributes) ⇒ Object
Class methods
52 53 54 55 |
# File 'lib/active_remote/serializers/protobuf.rb', line 52 def self.from_attributes(, attributes) fields = new(, attributes) fields.from_attributes end |
Instance Method Details
#from_attributes ⇒ Object
Instance methods
60 61 62 63 64 65 66 67 |
# File 'lib/active_remote/serializers/protobuf.rb', line 60 def from_attributes attributes.each_with_object({}) do |(key, value), hash| field = .get_field(key, true) # Check extension fields, too value = Field.from_attribute(field, value) if field hash[key] = value end end |