Module: Virtus::Extensions
- Included in:
- ClassMethods
- Defined in:
- lib/virtus/extensions.rb
Overview
Extensions common for both classes and instances
Constant Summary collapse
- WRITER_METHOD_REGEXP =
/=\z/.freeze
- INVALID_WRITER_METHODS =
%w[ == != === []= attributes= ].to_set.freeze
Instance Method Summary collapse
-
#allowed_writer_methods ⇒ Set
private
The list of writer methods that can be mass-assigned to in #attributes=.
-
#attribute(*args) ⇒ self
Defines an attribute on an object’s class.
Instance Method Details
#allowed_writer_methods ⇒ Set
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=
62 63 64 65 66 67 68 69 |
# File 'lib/virtus/extensions.rb', line 62 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 |