Get rid of unneded activesupport dep

This commit is contained in:
Tristan Druyen 2019-05-16 12:27:37 +02:00 committed by Anil Kumar Maurya
parent a00c96cf45
commit 1c5117720c
7 changed files with 8 additions and 7 deletions

View File

@ -141,7 +141,7 @@ module AASM
def aasm_column_is_blank?(state_machine_name)
attribute_name = self.class.aasm(state_machine_name).attribute_name
attribute_names.include?(attribute_name.to_s) && send(attribute_name).blank?
attribute_names.include?(attribute_name.to_s) && !send(attribute_name) || send(attribute_name).empty?
end
def aasm_validate_states

View File

@ -34,7 +34,7 @@ module AASM
# This allows for nil aasm states - be sure to add validation to your model
def aasm_read_state(name=:default)
state = send(self.class.aasm(name).attribute_name)
if state.blank?
if !state || state.empty?
aasm_new_record? ? aasm(name).determine_state_name(self.class.aasm(name).initial_state) : nil
else
state.to_sym

View File

@ -77,7 +77,8 @@ module AASM
#
def aasm_ensure_initial_state
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |state_machine_name|
send("#{self.class.aasm(state_machine_name).attribute_name}=", aasm(state_machine_name).enter_initial_state.to_s) if send(self.class.aasm(state_machine_name).attribute_name).blank?
next if !send(self.class.aasm(state_machine_name).attribute_name) || send(self.class.aasm(state_machine_name).attribute_name).empty?
send("#{self.class.aasm(state_machine_name).attribute_name}=", aasm(state_machine_name).enter_initial_state.to_s)
end
end
end # InstanceMethods

View File

@ -83,7 +83,7 @@ module AASM
#
def aasm_ensure_initial_state
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |state_machine_name|
aasm(state_machine_name).enter_initial_state if send(self.class.aasm(state_machine_name).attribute_name).blank?
aasm(state_machine_name).enter_initial_state if !send(self.class.aasm(state_machine_name).attribute_name) || send(self.class.aasm(state_machine_name).attribute_name).empty?
end
end
end # InstanceMethods

View File

@ -106,7 +106,7 @@ module AASM
# mongoid has_many relationship does not load child object attributes when
# only ids are loaded, for example parent.child_ids will not load child object attributes.
# This feature is introduced in mongoid > 4.
if attribute_names.include?(attribute_name) && attributes[attribute_name].blank?
if attribute_names.include?(attribute_name) && !attributes[attribute_name] || attributes[attribute_name].empty?
# attribute_missing? is defined in mongoid > 4
return if Mongoid::VERSION.to_f >= 4 && attribute_missing?(attribute_name)
send("#{self.class.aasm(state_machine_name).attribute_name}=", aasm(state_machine_name).enter_initial_state.to_s)

View File

@ -96,7 +96,7 @@ module AASM
def aasm_ensure_initial_state
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |name|
aasm_column = self.class.aasm(name).attribute_name
aasm(name).enter_initial_state if read_attribute(aasm_column).blank?
aasm(name).enter_initial_state if !read_attribute(aasm_column) || read_attribute(aasm_column).empty?
end
end
end # InstanceMethods

View File

@ -69,7 +69,7 @@ module AASM
def aasm_ensure_initial_state
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |name|
aasm_column = self.class.aasm(name).attribute_name
aasm(name).enter_initial_state if send(aasm_column).value.blank?
aasm(name).enter_initial_state if !send(aasm_column).value || send(aasm_column).value.empty?
end
end