Module: Virtus::Extensions::AllowedWriterMethods

Defined in:
lib/virtus/extensions.rb

Overview

Methods

Constant Summary collapse

WRITER_METHOD_REGEXP =
/=\z/.freeze
INVALID_WRITER_METHODS =
%w[ == != === []= attributes= ].to_set.freeze

Instance Method Summary collapse

Instance Method Details

#allowed_writer_methodsSet

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The list of writer methods that can be mass-assigned to in #attributes=

Returns:

  • (Set)


100
101
102
103
104
105
106
107
# File 'lib/virtus/extensions.rb', line 100

def allowed_writer_methods
  @allowed_writer_methods ||=
    begin
      allowed_writer_methods  = allowed_methods.grep(WRITER_METHOD_REGEXP).to_set
      allowed_writer_methods -= INVALID_WRITER_METHODS
      allowed_writer_methods.freeze
    end
end