mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
* Add change name rule for transaction * Use HTML template in the ERB, clone and inject those templates from the stimulus controller * Put back the ai_enabled check * Update docs * Example of what no case statement would look like * Remove action_type and needs_value now that controller is injecting templates/hiding action target * add "to" to template, improve no-option selection, ensure text box is cleared
43 lines
626 B
Ruby
43 lines
626 B
Ruby
class Rule::ActionExecutor
|
|
TYPES = [ "select", "function", "text" ]
|
|
|
|
def initialize(rule)
|
|
@rule = rule
|
|
end
|
|
|
|
def key
|
|
self.class.name.demodulize.underscore
|
|
end
|
|
|
|
def label
|
|
key.humanize
|
|
end
|
|
|
|
def type
|
|
"function"
|
|
end
|
|
|
|
def options
|
|
nil
|
|
end
|
|
|
|
def execute(scope, value: nil, ignore_attribute_locks: false)
|
|
raise NotImplementedError, "Action executor #{self.class.name} must implement #execute"
|
|
end
|
|
|
|
def as_json
|
|
{
|
|
type: type,
|
|
key: key,
|
|
label: label,
|
|
options: options
|
|
}
|
|
end
|
|
|
|
private
|
|
attr_reader :rule
|
|
|
|
def family
|
|
rule.family
|
|
end
|
|
end
|