Skip to content

Commit

Permalink
rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
takahashim committed Aug 14, 2024
1 parent 15ec782 commit 2c050b8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/review/book/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def reset

# key should be Symbol, not String
def fetch(key, &block)
raise ArgumentError, 'Key should be Symbol' unless key.kind_of?(Symbol)
if has_key?(key)
raise ArgumentError, 'Key should be Symbol' unless key.is_a?(Symbol)

if key?(key)
read(key)
else
exec_block_and_save(key, &block)
Expand All @@ -29,8 +30,8 @@ def fetch(key, &block)

private

def has_key?(key)
@store.has_key?(key)
def key?(key)
@store.key?(key)
end

def read(key)
Expand All @@ -41,7 +42,7 @@ def write(key, value)
@store[key] = value
end

def exec_block_and_save(key, &block)
def exec_block_and_save(key)
result = yield(key)

write(key, result)
Expand Down

0 comments on commit 2c050b8

Please sign in to comment.