mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Get rid of unneded activesupport dep
This commit is contained in:
parent
a00c96cf45
commit
1c5117720c
7 changed files with 8 additions and 7 deletions
|
@ -141,7 +141,7 @@ module AASM
|
||||||
|
|
||||||
def aasm_column_is_blank?(state_machine_name)
|
def aasm_column_is_blank?(state_machine_name)
|
||||||
attribute_name = self.class.aasm(state_machine_name).attribute_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
|
end
|
||||||
|
|
||||||
def aasm_validate_states
|
def aasm_validate_states
|
||||||
|
|
|
@ -34,7 +34,7 @@ module AASM
|
||||||
# This allows for nil aasm states - be sure to add validation to your model
|
# This allows for nil aasm states - be sure to add validation to your model
|
||||||
def aasm_read_state(name=:default)
|
def aasm_read_state(name=:default)
|
||||||
state = send(self.class.aasm(name).attribute_name)
|
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
|
aasm_new_record? ? aasm(name).determine_state_name(self.class.aasm(name).initial_state) : nil
|
||||||
else
|
else
|
||||||
state.to_sym
|
state.to_sym
|
||||||
|
|
|
@ -77,7 +77,8 @@ module AASM
|
||||||
#
|
#
|
||||||
def aasm_ensure_initial_state
|
def aasm_ensure_initial_state
|
||||||
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |state_machine_name|
|
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
|
end
|
||||||
end # InstanceMethods
|
end # InstanceMethods
|
||||||
|
|
|
@ -83,7 +83,7 @@ module AASM
|
||||||
#
|
#
|
||||||
def aasm_ensure_initial_state
|
def aasm_ensure_initial_state
|
||||||
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |state_machine_name|
|
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
|
end
|
||||||
end # InstanceMethods
|
end # InstanceMethods
|
||||||
|
|
|
@ -106,7 +106,7 @@ module AASM
|
||||||
# mongoid has_many relationship does not load child object attributes when
|
# 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.
|
# only ids are loaded, for example parent.child_ids will not load child object attributes.
|
||||||
# This feature is introduced in mongoid > 4.
|
# 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
|
# attribute_missing? is defined in mongoid > 4
|
||||||
return if Mongoid::VERSION.to_f >= 4 && attribute_missing?(attribute_name)
|
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)
|
send("#{self.class.aasm(state_machine_name).attribute_name}=", aasm(state_machine_name).enter_initial_state.to_s)
|
||||||
|
|
|
@ -96,7 +96,7 @@ module AASM
|
||||||
def aasm_ensure_initial_state
|
def aasm_ensure_initial_state
|
||||||
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |name|
|
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |name|
|
||||||
aasm_column = self.class.aasm(name).attribute_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
|
end
|
||||||
end # InstanceMethods
|
end # InstanceMethods
|
||||||
|
|
|
@ -69,7 +69,7 @@ module AASM
|
||||||
def aasm_ensure_initial_state
|
def aasm_ensure_initial_state
|
||||||
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |name|
|
AASM::StateMachineStore.fetch(self.class, true).machine_names.each do |name|
|
||||||
aasm_column = self.class.aasm(name).attribute_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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue