Class: Melos::Struct::FramedContentAuthData
- Defined in:
- lib/melos/struct/structs.rb
Constant Summary collapse
- STRUCT =
[ [:signature, :vec] ]
Instance Attribute Summary collapse
-
#confirmation_tag ⇒ Object
readonly
Returns the value of attribute confirmation_tag.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#signature ⇒ Object
readonly
Returns the value of attribute signature.
Class Method Summary collapse
- .create(signature:, content_type:, confirmation_tag:) ⇒ Object
-
.new_with_content_type(stream, content_type) ⇒ Object
initialize from stream.
Instance Method Summary collapse
Methods inherited from Base
#deserialize_select_elem_with_context, #initialize
Constructor Details
This class inherits a constructor from Melos::Struct::Base
Instance Attribute Details
#confirmation_tag ⇒ Object (readonly)
Returns the value of attribute confirmation_tag.
634 635 636 |
# File 'lib/melos/struct/structs.rb', line 634 def confirmation_tag @confirmation_tag end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
634 635 636 |
# File 'lib/melos/struct/structs.rb', line 634 def content_type @content_type end |
#signature ⇒ Object (readonly)
Returns the value of attribute signature.
634 635 636 |
# File 'lib/melos/struct/structs.rb', line 634 def signature @signature end |
Class Method Details
.create(signature:, content_type:, confirmation_tag:) ⇒ Object
663 664 665 666 667 668 669 670 671 |
# File 'lib/melos/struct/structs.rb', line 663 def self.create(signature:, content_type:, confirmation_tag:) instance = self.allocate instance.instance_variable_set(:@signature, signature) instance.instance_variable_set(:@content_type, content_type) if content_type == Melos::Constants::ContentType::COMMIT instance.instance_variable_set(:@confirmation_tag, confirmation_tag) end instance end |
.new_with_content_type(stream, content_type) ⇒ Object
initialize from stream
641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/melos/struct/structs.rb', line 641 def self.new_with_content_type(stream, content_type) instance = self.allocate context = instance.send(:deserialize, stream) # custom part based on instance variable if content_type == Melos::Constants::ContentType::COMMIT # commit # read MAC(opaque <V>) confirmation_tag value = Melos::Vec.parse_stringio(stream) context << [:confirmation_tag, value] end context << [:content_type, content_type] instance.send(:set_instance_vars, context) instance end |
Instance Method Details
#raw ⇒ Object
655 656 657 658 659 660 661 |
# File 'lib/melos/struct/structs.rb', line 655 def raw if @content_type == Melos::Constants::ContentType::COMMIT Melos::Vec.from_string(@signature) + Melos::Vec.from_string(@confirmation_tag) else Melos::Vec.from_string(@signature) end end |