Skip to content

Commit 7ecb025

Browse files
committed
feat: add ArgumentSet#empty?
Returns whether an argument set has no arguments provided or not.
1 parent 43c1c74 commit 7ecb025

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/apia/argument_set.rb

+7
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,13 @@ def has?(key)
122122
@source.key?(key.to_sym)
123123
end
124124

125+
# Return whether the argument set has no arguments within?
126+
#
127+
# @return [Boolean]
128+
def empty?
129+
@source.empty?
130+
end
131+
125132
# Validate an argument set and return any errors as appropriate
126133
#
127134
# @param argument [Apia::Argument]

spec/specs/apia/argument_set_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,24 @@
416416
end
417417
end
418418

419+
context '#empty' do
420+
it 'is true if there are no arguments' do
421+
as = Apia::ArgumentSet.create('ExampleSet') do
422+
argument :name, type: :string
423+
end
424+
instance = as.new({})
425+
expect(instance.empty?).to be true
426+
end
427+
428+
it 'is false if there are arguments' do
429+
as = Apia::ArgumentSet.create('ExampleSet') do
430+
argument :name, type: :string
431+
end
432+
instance = as.new({ name: 'Dave' })
433+
expect(instance.empty?).to be false
434+
end
435+
end
436+
419437
context '#to_hash' do
420438
it 'should return a hash of the values' do
421439
as = Apia::ArgumentSet.create('ExampleSet') do

0 commit comments

Comments
 (0)