Class: Mihari::Web::Endpoints::Rules::RuleCreateUpdater
- Inherits:
-
Service
- Object
- Service
- Mihari::Web::Endpoints::Rules::RuleCreateUpdater
show all
- Defined in:
- lib/mihari/web/endpoints/rules.rb
Instance Method Summary
collapse
Methods inherited from Service
call, #get_result, get_result
Instance Method Details
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/mihari/web/endpoints/rules.rb', line 17
def call(yaml, overwrite: true)
rule = Rule.from_yaml(yaml)
Models::Rule.find(rule.id) if overwrite
raise IntegrityError, "ID:#{rule.id} already registered" if rule.exists? && !overwrite
rule.update_or_create
rule
end
|