0

yes, I want to append a CONSTANT,

I have an array that is stored as a constant in the mainapp, something like

class FOO
  ABILITY = [["xxxx","XX"],["yy","YYY"]]
end

above constant is used throughout the mainapp in various ways.

now, I have a rails engine that extends the mainapps abilities, and would like to extend the ABILITY array in the main app so if I where to do a

ABILITY.each

i would get an extra pair.

Without thinking, I just did a

class BAR
  FOO::ABILITY << ["zzzz","ZZZZ"]
end

of course this didn't do anything.

I have never considered appending a constant, which in its self seems like a bad thing to do, but considering the purpose of the RailsEngine, for it feels like an adequate idea, thanks in advance.

Saifis
  • 2,197
  • 1
  • 22
  • 36

1 Answers1

0
class FOO
  ABILITY = [["xxx","XX"],["yy","yyyy"]]
end

class BAR
  T= FOO::ABILITY << ["zzz","ZZ"]
end

BAR::T
=> [["xxx", "XX"], ["yy", "yyyy"], ["zzz", "ZZ"]]

you were missing a "," in your ABILITY array. Does that help?

Chris Lewis
  • 1,315
  • 10
  • 25