Skip to content

Commit

Permalink
fix for MongoMapper
Browse files Browse the repository at this point in the history
  • Loading branch information
alto committed May 5, 2015
1 parent 5c0e086 commit ed26b26
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/aasm/persistence/mongo_mapper_persistence.rb
Expand Up @@ -107,21 +107,21 @@ def aasm_write_state_without_persistence(state, name=:default)
end

private
def aasm_enum
case AASM::StateMachine[self.class].config.enum
def aasm_enum(name=:default)
case AASM::StateMachine[self.class][name].config.enum
when false then nil
when true then aasm_guess_enum_method
when nil then aasm_guess_enum_method if aasm_column_looks_like_enum
else AASM::StateMachine[self.class].config.enum
when true then aasm_guess_enum_method(name)
when nil then aasm_guess_enum_method(name) if aasm_column_looks_like_enum(name)
else AASM::StateMachine[self.class][name].config.enum
end
end

def aasm_column_looks_like_enum
self.class.keys[self.class.aasm.attribute_name.to_s].type == Integer
def aasm_column_looks_like_enum(name)
self.class.keys[self.class.aasm(name).attribute_name.to_s].type == Integer
end

def aasm_guess_enum_method
self.class.aasm.attribute_name.to_s.pluralize.to_sym
def aasm_guess_enum_method(name)
self.class.aasm(name).attribute_name.to_s.pluralize.to_sym
end

def aasm_skipping_validations(state_machine_name)
Expand Down

0 comments on commit ed26b26

Please sign in to comment.