Skip to content

Instantly share code, notes, and snippets.

@joshuaclayton
Created June 11, 2009 20:45
Show Gist options
  • Save joshuaclayton/128226 to your computer and use it in GitHub Desktop.
Save joshuaclayton/128226 to your computer and use it in GitHub Desktop.
def self.private_attributes(*args)
@@private_attributes = [args].flatten
class_eval do
def method_missing_with_private_accessor(call, *args)
method_missing_without_private_accessor(call, *args) unless @@private_attributes.map(&:to_sym).include?(call.to_sym)
end
alias_method_chain :method_missing, :private_accessor
end
end
private_attributes :published=, :title=, :title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment