1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

Do not define column setter for absctract class

This commit is contained in:
Anil Maurya 2019-04-21 13:04:52 +05:30 committed by Anil Kumar Maurya
parent 4427c353a3
commit 23f98a100d

View file

@ -54,6 +54,8 @@ module AASM
# make sure to raise an error if no_direct_assignment is enabled
# and attribute is directly assigned though
aasm_name = @name
if !(klass.superclass.methods.include?(:abstract_class) &&
klass.superclass.abstract_class)
klass.send :define_method, "#{@state_machine.config.column}=", ->(state_name) do
if self.class.aasm(:"#{aasm_name}").state_machine.config.no_direct_assignment
raise AASM::NoDirectAssignmentError.new(
@ -64,6 +66,7 @@ module AASM
end
end
end
end
# This method is both a getter and a setter
def attribute_name(column_name=nil)