Skip to content

Commit

Permalink
Merge pull request #476 from chopraanmol1/ruby_fix_instance_variable_…
Browse files Browse the repository at this point in the history
…not_initialized_warning

Fix "instance variable not initialized" warning
  • Loading branch information
chopraanmol1 authored Dec 26, 2018
2 parents b6d6479 + b868e63 commit 5a3e76a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/roo/excelx/cell/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def type
end

def formula?
!!@formula
!!(defined?(@formula) && @formula)
end

def link?
Expand Down
2 changes: 1 addition & 1 deletion lib/roo/helpers/weak_instance_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module WeakInstanceCache
def instance_cache(key)
object = nil

if (ref = instance_variable_get(key)) && ref.weakref_alive?
if instance_variable_defined?(key) && (ref = instance_variable_get(key)) && ref.weakref_alive?
begin
object = ref.__getobj__
rescue => e
Expand Down
2 changes: 1 addition & 1 deletion test/excelx/cell/test_attr_reader_default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_cell_default_values
def assert_values(object, value_hash)
value_hash.each do |attr_name, expected_value|
value = if attr_name.to_s.include?("@")
object.instance_variable_get(attr_name)
object.instance_variable_defined?(attr_name) ? object.instance_variable_get(attr_name) : nil
else
object.public_send(attr_name)
end
Expand Down

0 comments on commit 5a3e76a

Please sign in to comment.