Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Hash#compact instead of rejecting nil values #56

Merged
merged 1 commit into from May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/cose/key/base.rb
Expand Up @@ -41,14 +41,12 @@ def serialize
end

def map
map = {
{
LABEL_BASE_IV => base_iv,
LABEL_KEY_OPS => key_ops,
LABEL_ALG => alg,
LABEL_KID => kid,
}

map.reject { |_k, v| v.nil? }
}.compact
end
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/cose/key/curve_key.rb
Expand Up @@ -35,13 +35,11 @@ def initialize(crv:, x: nil, d: nil, **keyword_arguments) # rubocop:disable Nami
end

def map
map = super.merge(
super.merge(
LABEL_CRV => crv,
LABEL_X => x,
LABEL_D => d
)

map.reject { |_k, v| v.nil? }
).compact
end
end
end
Expand Down
6 changes: 2 additions & 4 deletions lib/cose/key/ec2.rb
Expand Up @@ -59,12 +59,10 @@ def initialize(y: nil, **keyword_arguments) # rubocop:disable Naming/MethodParam
end

def map
map = super.merge(
super.merge(
Base::LABEL_KTY => KTY_EC2,
LABEL_Y => y,
)

map.reject { |_k, v| v.nil? }
).compact
end

def to_pkey
Expand Down
6 changes: 2 additions & 4 deletions lib/cose/key/rsa.rb
Expand Up @@ -74,7 +74,7 @@ def initialize(n:, e:, d: nil, p: nil, q: nil, dp: nil, dq: nil, qinv: nil, **ke
end

def map
map = super.merge(
super.merge(
Base::LABEL_KTY => KTY_RSA,
LABEL_N => n,
LABEL_E => e,
Expand All @@ -84,9 +84,7 @@ def map
LABEL_DP => dp,
LABEL_DQ => dq,
LABEL_QINV => qinv
)

map.reject { |_k, v| v.nil? }
).compact
end

def to_pkey
Expand Down