This helps with writing extensions to the AR adapters. For instance, I'd like to write an adapter which uses AR::Enum to store the workflow state instead of a string. Model.with_some_state will always evaluate to where(workflow_state: :some) (see lib/workflow/adapters/active_record.rb).
My suggestion is to change
eigenclass.send(:define_method, "with_#{state}_state") do
where("#{table_name}.#{self.workflow_column.to_sym} = ?", state.to_s)
end
to
eigenclass.send(:define_method, "with_#{state}_state") do
with_workflow_state(state)
end
And then defining
def with_workflow_state(state)
where("#{table_name}.#{self.workflow_column.to_sym} = ?", state.to_s)
end
This way my custom adapter can write:
def with_workflow_state(state)
super(statuses[state])
end
This helps with writing extensions to the AR adapters. For instance, I'd like to write an adapter which uses AR::Enum to store the workflow state instead of a string.
Model.with_some_state
will always evaluate towhere(workflow_state: :some)
(see lib/workflow/adapters/active_record.rb).My suggestion is to change
to
And then defining
This way my custom adapter can write:
Just a suggestion.