Module: Redmine::SafeAttributes::ClassMethods

Defined in:
lib/redmine/safe_attributes.rb

Instance Method Summary collapse

Instance Method Details

#safe_attributes(*args) ⇒ Object

Declares safe attributes An optional Proc can be given for conditional inclusion

Example:

safe_attributes 'title', 'pages'
safe_attributes 'isbn', :if => {|book, user| book.author == user}


31
32
33
34
35
36
37
38
39
# File 'lib/redmine/safe_attributes.rb', line 31

def safe_attributes(*args)
  @safe_attributes ||= []
  if args.empty?
    @safe_attributes
  else
    options = args.last.is_a?(Hash) ? args.pop : {}
    @safe_attributes << [args, options]
  end
end