Skip to content
Snippets Groups Projects
Verified Commit 2f7e2d79 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

Refactored the name of frames

parent f41736bf
No related branches found
No related tags found
No related merge requests found
...@@ -39,7 +39,7 @@ module Apex ...@@ -39,7 +39,7 @@ module Apex
path = Apex::Path.from_raw(frame_map[:path]) path = Apex::Path.from_raw(frame_map[:path])
return Apex::Frame.new(source, destination, path, frame_map[:payload]) return Apex::ImmutableFrame.new(source, destination, path, frame_map[:payload])
end end
public public
......
...@@ -60,7 +60,7 @@ module Apex ...@@ -60,7 +60,7 @@ module Apex
decoded_path = Apex::Path.from_raw(path) decoded_path = Apex::Path.from_raw(path)
decoded_payload = frame_so_far decoded_payload = frame_so_far
return Apex::Frame.new(decoded_source, decoded_destination, decoded_path, decoded_payload) return Apex::ImmutableFrame.new(decoded_source, decoded_destination, decoded_path, decoded_payload)
end end
private private
......
require 'apex/frame/frame' require 'apex/frame/immutable_frame'
require 'apex/frame/entity' require 'apex/frame/entity'
require 'apex/frame/hop' require 'apex/frame/hop'
require 'apex/frame/path' require 'apex/frame/path'
require 'apex/frame/unpathed_frame' require 'apex/frame/immutable_message'
require 'apex/frame/path_agnostic_frame' require 'apex/frame/path_agnostic_immutable_frame'
require 'apex/frame/unpathed_frame' require 'apex/frame/immutable_message'
module Apex module Apex
public public
class Frame < Apex::UnpathedFrame class ImmutableFrame < Apex::ImmutableMessage
attr_accessor :path attr_accessor :path
protected protected
...@@ -17,8 +17,8 @@ module Apex ...@@ -17,8 +17,8 @@ module Apex
public public
def eql?(other) def eql?(other)
raise ArgumentError.new("The argument can not be a UnpathedFrame or a PathAgnosticFrame") if ((other.instance_of? UnpathedFrame) || (other.instance_of? PathAgnosticFrame)) raise ArgumentError.new("The argument can not be a UnpathedFrame or a PathAgnosticFrame") if ((other.instance_of? ImmutableMessage) || (other.instance_of? PathAgnosticImmutableFrame))
raise ArgumentError.new("The argument must be of type Frame (or a child class).") if not other.kind_of? Frame raise ArgumentError.new("The argument must be of type Frame (or a child class).") if not other.kind_of? ImmutableFrame
return self == other return self == other
end end
...@@ -43,7 +43,7 @@ module Apex ...@@ -43,7 +43,7 @@ module Apex
public public
def path_agnostic_identity def path_agnostic_identity
return PathAgnosticFrame.new(self.source, self.destination, self.path, self.payload) return PathAgnosticImmutableFrame.new(self.source, self.destination, self.path, self.payload)
end end
end end
end end
...@@ -8,7 +8,7 @@ module Apex ...@@ -8,7 +8,7 @@ module Apex
# diff_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload') # diff_frame = Apex.new('WI2ARD-1', 'OMG', ['WIDE2-2' 'WIDE1-1'], 'different payload')
# assert not orig_frame.eql? diff_frame # assert not orig_frame.eql? diff_frame
public public
class UnpathedFrame class ImmutableMessage
attr_accessor :source, :destination, :payload attr_accessor :source, :destination, :payload
## ##
...@@ -41,7 +41,7 @@ module Apex ...@@ -41,7 +41,7 @@ module Apex
public public
def path_agnostic_eql?(other) def path_agnostic_eql?(other)
raise ArgumentError.new("The argument must be either an UnpathedFrame or a PathAgnosticFrame") if not ((other.instance_of? Apex::UnpathedFrame) || (other.instance_of? Apex::PathAgnosticFrame)) raise ArgumentError.new("The argument must be either an ImmutableMessage or a PathAgnosticFrame") if not ((other.instance_of? Apex::ImmutableMessage) || (other.instance_of? Apex::PathAgnosticImmutableFrame))
return self.path_agnostic_equality? other return self.path_agnostic_equality? other
end end
......
module Apex module Apex
private private
class PathAgnosticFrame < Frame class PathAgnosticImmutableFrame < ImmutableFrame
protected protected
def initialize(source, destination, path, payload) def initialize(source, destination, path, payload)
super(source, destination, path, payload) super(source, destination, path, payload)
......
require_relative '../../../lib/apex' require_relative '../../../lib/apex'
FRAME_KISS = Apex::Frame.new( FRAME_KISS = Apex::ImmutableFrame.new(
Apex::Entity.from_raw('W2GMD-1'), Apex::Entity.from_raw('W2GMD-1'),
Apex::Entity.from_raw('OMG'), Apex::Entity.from_raw('OMG'),
Apex::Path.from_raw(['WIDE1-1', 'WIDE2-2']), Apex::Path.from_raw(['WIDE1-1', 'WIDE2-2']),
......
require_relative '../../../lib/apex' require_relative '../../../lib/apex'
DECODED_FRAME_IGATE = Apex::Frame.new( DECODED_FRAME_IGATE = Apex::ImmutableFrame.new(
Apex::Entity.from_raw('W2GMD-1'), Apex::Entity.from_raw('W2GMD-1'),
Apex::Entity.from_raw('OMG'), Apex::Entity.from_raw('OMG'),
Apex::Path.from_raw(['WIDE1-1', 'WIDE2-2']), Apex::Path.from_raw(['WIDE1-1', 'WIDE2-2']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment