Skip to content
Browse files

Remove AllowedWriterMethods

  • Loading branch information...
1 parent 6f6e96e commit 7e30658cc2617cb8956b9e3b8cc54e583dec0d2c @solnic committed Jun 4, 2012
View
1 lib/virtus/class_inclusions.rb
@@ -4,7 +4,6 @@ module ClassInclusions
def self.included(descendant)
super
descendant.extend(ClassMethods)
- descendant.extend(InstanceExtensions::AllowedWriterMethods)
descendant.send(:include, InstanceMethods)
end
View
31 lib/virtus/instance_extensions.rb
@@ -2,28 +2,25 @@ module Virtus
# Instance-level extensions
module InstanceExtensions
- module AllowedWriterMethods
- WRITER_METHOD_REGEXP = /=\z/.freeze
- INVALID_WRITER_METHODS = %w[ == != === []= attributes= ].to_set.freeze
+ WRITER_METHOD_REGEXP = /=\z/.freeze
+ INVALID_WRITER_METHODS = %w[ == != === []= attributes= ].to_set.freeze
- # The list of writer methods that can be mass-assigned to in #attributes=
- #
- # @return [Set]
- #
- # @api private
- def allowed_writer_methods
- @allowed_writer_methods ||=
- begin
- allowed_writer_methods = public_method_list.map(&:to_s)
- allowed_writer_methods = allowed_writer_methods.grep(WRITER_METHOD_REGEXP).to_set
- allowed_writer_methods -= INVALID_WRITER_METHODS
- allowed_writer_methods.freeze
- end
+ # The list of writer methods that can be mass-assigned to in #attributes=
+ #
+ # @return [Set]
+ #
+ # @api private
+ def allowed_writer_methods
+ @allowed_writer_methods ||=
+ begin
+ allowed_writer_methods = public_method_list.map(&:to_s)
+ allowed_writer_methods = allowed_writer_methods.grep(WRITER_METHOD_REGEXP).to_set
+ allowed_writer_methods -= INVALID_WRITER_METHODS
+ allowed_writer_methods.freeze
end
end
def self.extended(object)
- object.extend(AllowedWriterMethods)
object.extend(InstanceMethods)
object.instance_eval do
@virtus_attributes_accessor_module = AttributesAccessor.new(object.class.inspect)
View
2 ...ss_methods/allowed_writer_methods_spec.rb → ...extensions/allowed_writer_methods_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe Virtus::InstanceExtensions::AllowedWriterMethods, '#allowed_writer_methods' do
+describe Virtus::InstanceExtensions, '#allowed_writer_methods' do
subject { object.allowed_writer_methods }
let(:object) do

0 comments on commit 7e30658

Please sign in to comment.
Something went wrong with that request. Please try again.