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:
parent
4427c353a3
commit
23f98a100d
1 changed files with 10 additions and 7 deletions
|
@ -54,13 +54,16 @@ module AASM
|
|||
# make sure to raise an error if no_direct_assignment is enabled
|
||||
# and attribute is directly assigned though
|
||||
aasm_name = @name
|
||||
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(
|
||||
'direct assignment of AASM column has been disabled (see AASM configuration for this class)'
|
||||
)
|
||||
else
|
||||
super(state_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(
|
||||
'direct assignment of AASM column has been disabled (see AASM configuration for this class)'
|
||||
)
|
||||
else
|
||||
super(state_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue