Skip to content

Commit

Permalink
Add attr writers to Pio::Match and Pio::ExactMatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Mar 12, 2015
1 parent dea4c16 commit ebf177f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 38 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,8 @@
# Changelog

## develop (unreleased)
### New features
* Add attr writers to `Pio::Match` and `Pio::ExactMatch`.


## 0.18.1 (3/11/2015)
Expand Down
20 changes: 3 additions & 17 deletions lib/pio/exact_match.rb
Expand Up @@ -44,22 +44,8 @@ def initialize(packet_in)
# rubocop:enable MethodLength
# rubocop:enable AbcSize

extend Forwardable

def_delegator :@match, :wildcards
def_delegator :@match, :in_port
def_delegator :@match, :dl_src
def_delegator :@match, :dl_dst
def_delegator :@match, :dl_vlan
def_delegator :@match, :dl_vlan_pcp
def_delegator :@match, :dl_type
def_delegator :@match, :nw_tos
def_delegator :@match, :nw_proto
def_delegator :@match, :nw_src
def_delegator :@match, :nw_dst
def_delegator :@match, :tp_src
def_delegator :@match, :tp_dst
def_delegator :@match, :to_binary_s
def_delegator :@match, :to_binary_s, :to_binary
def method_missing(method, *args, &block)
@match.__send__ method, *args, &block
end
end
end
29 changes: 8 additions & 21 deletions lib/pio/match.rb
Expand Up @@ -3,7 +3,6 @@
require 'pio/open_flow'
require 'pio/type/ip_address'
require 'pio/type/mac_address'
require 'forwardable'

module Pio
# Fields to match against flows
Expand Down Expand Up @@ -127,26 +126,6 @@ def self.read(binary)
MatchFormat.read binary
end

extend Forwardable

def_delegators :@format, :wildcards
def_delegators :@format, :in_port
def_delegators :@format, :dl_vlan
def_delegators :@format, :dl_src
def_delegators :@format, :dl_dst
def_delegators :@format, :dl_type
def_delegators :@format, :nw_proto
def_delegators :@format, :tp_src
def_delegators :@format, :tp_dst
def_delegators :@format, :nw_src
def_delegators :@format, :nw_src_all
def_delegators :@format, :nw_dst
def_delegators :@format, :nw_dst_all
def_delegators :@format, :dl_vlan_pcp
def_delegators :@format, :nw_tos
def_delegators :@format, :to_binary_s
def_delegator :@format, :to_binary_s, :to_binary

# rubocop:disable MethodLength
# This method smells of :reek:FeatureEnvy
# This method smells of :reek:DuplicateMethodCall
Expand All @@ -165,9 +144,17 @@ def initialize(user_options)
end
# rubocop:enable MethodLength

def to_binary
@format.to_binary_s
end

def ==(other)
return false unless other
to_binary == other.to_binary
end

def method_missing(method, *args, &block)
@format.__send__ method, *args, &block
end
end
end

0 comments on commit ebf177f

Please sign in to comment.