0

In rails, this is a common pattern:

def foo_with_feature
  add_feature_to foo_without_feature
end

alias_method_chain :foo, :feature

I want to do this but with an attribute, whose getter method is not defined and will be done on-the-fly with method_missing, see Why alias_method fails in Rails model

How can I decorate an attribute getter that hasn't been set?

Community
  • 1
  • 1
Shelvacu
  • 4,245
  • 25
  • 44

1 Answers1

0

Simply access the attribute directly like so:

def fooattr_raw
  self.attributes["fooattr"]
end

def fooattr
  add_feature_to fooattr_raw
end
Shelvacu
  • 4,245
  • 25
  • 44