Question on openstruct objects in ruby

I am creating an openstruct in ruby and trying to access its “suppress”
attribute but I get the “LocalJumpError” but when I try any other
attribute it looks ok…

Any idea why??

irb(main):168:0>
irb(main):169:0* australia = OpenStruct.new(:country => “Australia”,
:population => 20_000_000)

=> #<OpenStruct country=“Australia”, population=20000000>
irb(main):170:0> australia = OpenStruct.new(:country => “Australia”,
:population => 20_000_000, :suppress => “suppress”)

=> #<OpenStruct country=“Australia”, population=20000000,
suppress=“suppress”>

irb(main):171:0> australia.suppress
LocalJumpError: no block given (yield)
from
/usr/lib/ruby/gems/2.1.0/gems/activesupport-3.2.17/lib/active_support/core_ext/kernel/reporting.rb:59:in
suppress' from (irb):171 from /usr/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/commands/console.rb:47:instart’
from
/usr/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/commands/console.rb:8:in
start' from /usr/lib/ruby/gems/2.1.0/gems/railties-3.2.17/lib/rails/commands.rb:41:in<top (required)>’
from script/rails:6:in require' from script/rails:6:in

irb(main):174:0> australia.population
=> 20000000

Nice one.

Although I am not programming rails, nor have any knowledge of
ActiveSupport, I venture, that ActiveSupport adds a “suppress()” method
to your OpenStruct class. How this is done I ignore and also do not need
to know.

To access the values which you want to store in the OpenStruct, just use
a new name for the property, different from “supppress”.

Having no use or ActiveSupport, my execution of your example works as
expected:

australia = OpenStruct.new(:country => “Australia”,
:population => 20_000_000, :suppress => “suppress”)
=> #<OpenStruct country=“Australia”, population=20000000,
suppress=“suppress”>
irb(main):004:0> australia.suppress
=> “suppress”

Cheerio,

Michael

Okay, my hint was worth nothing, it seems.