Custom resource

I am new to chef and I'm in the process of learning both Chef and Ruby, so I fully admit that this might be a very basic question that I just can't see the answer to. I've tried searching for a solution but have not found any examples or guidance on how to proceed with what I am trying to accomplish.

For demo purposes I have created a new cookbook using the following commands:

chef generate cookbook demo
chef generate attribute default
chef generate resource package

recipes\default.rb

demo_package 'Demo'

resources\package.rb

property :resource_prop1, String
property :resource_prop2, String

default_action :install

load_current_value do
  puts
  puts "the current value before change for 'test_prop1': #{resource_prop1}"
  puts "the current value before change for 'test_prop2': #{resource_prop2}"
  resource_prop1 = node['demo_resource']['test_prop1']
  resource_prop2 = node['demo_resource']['test_prop2']
  puts "the current value after change for 'test_prop1': #{resource_prop1}"
  puts "the current value after change for 'test_prop2': #{resource_prop2}"
end

action :install do
    puts "the current value after load properties for 'test_prop1': #{new_resource.resource_prop1}"
    puts "the current value after load properties for 'test_prop2': #{new_resource.resource_prop2}"
end

attributes\default.rb

default['demo_resource'] = {}
default['demo_resource']['test_prop1'] = 'test value 1'
default['demo_resource']['test_prop2'] = 'test value 2'

I am expecting the output to look like this:

the current value before change for 'test_prop1':
the current value before change for 'test_prop2':
the current value after change for 'test_prop1': test value 1
the current value after change for 'test_prop2': test value 2
the current value after load properties for 'test_prop1': test value 1
the current value after load properties for 'test_prop2': test value 2

but what I actually get is:

the current value before change for 'test_prop1':
the current value before change for 'test_prop2':
the current value after change for 'test_prop1': test value 1
the current value after change for 'test_prop2': test value 2
the current value after load properties for 'test_prop1': 
the current value after load properties for 'test_prop2':

I have tried changing this line:
puts "the current value after load properties for 'test_prop1': #{new_resource.resource_prop1}"
into this
puts "the current value after load properties for 'test_prop1': #{resource_prop1}"

But I get this error:

NameError
undefined local variable or method `resource_prop1' for #<#Class:0x0000000007b51178>:0x00000000084b3680>
Did you mean?  resources

Does anyone have any idea what I might be doing wrong?

This line in load_current values populates current_resource and doesn't update new_resource.

The goal is to be able to use converge_if_changed :resource_prop1 (which will compare resource_prop1 between current_resource and new_resource to act or not)

Useful links:

@Tensibai If I understand your response I think it tracks with the solution\workaround that I found. I changed the line in question to:

package.resource_prop1 = node['demo_resource']['test_prop1']

and that seemed to fix the issue and everything proceeded as expected.