Module: Forcast::Model::RuleEngine
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/forcast/models/rule_engine/rule.rb,
lib/forcast/models/rule_engine/rule_scope.rb,
lib/forcast/models/rule_engine/rule_engine.rb,
lib/forcast/models/rule_engine/action_engine.rb,
lib/forcast/models/rule_engine/polling_engine.rb,
lib/forcast/models/rule_engine/webhook_engine.rb
Defined Under Namespace
Modules: ActionEngine, PollingEngine, RuleEngine, RuleScope, WebhookEngine
Instance Method Summary
collapse
Instance Method Details
#class_polling ⇒ Object
12
13
14
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 12
def class_polling
Polling.where(polling_model: self.class.name, class_polling?: true)
end
|
#class_rule ⇒ Object
16
17
18
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 16
def class_rule
Rule.for_class(self.class.name)
end
|
#currents_pollings ⇒ Object
54
55
56
57
58
59
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 54
def currents_pollings
arr1 = polling.where(created_at: 4.week.ago.beginning_of_day..Time.now)
.where(active?: true)
arr2 = class_polling.where(active?: true)
arr2 + arr1
end
|
#object_webhook ⇒ Object
24
25
26
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 24
def object_webhook
Webhook.joins(:rule).merge(Rule.for_object(self))
end
|
#polling ⇒ Object
28
29
30
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 28
def polling
Polling.where(polling_model: self.class.name, polling_model_id: id)
end
|
#rule ⇒ Object
32
33
34
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 32
def rule
Rule.for_object_and_class(self)
end
|
#send_webhook_create ⇒ Object
36
37
38
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 36
def send_webhook_create
puts 'send_webhook_create'
end
|
#send_webhook_destroy ⇒ Object
40
41
42
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 40
def send_webhook_destroy
puts 'send_webhook_destroy'
end
|
#send_webhook_update ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 44
def send_webhook_update
puts 'send_webhook_update'
JobsWebhooks::ValidateModelWebhook.perform_later(
webhook_model: self.class.name,
webhook_model_id: id,
changed_attrs_json: saved_changes.to_json,
created_at: Time.now.to_s
)
end
|
#webhook ⇒ Object
20
21
22
|
# File 'lib/forcast/models/rule_engine/rule.rb', line 20
def webhook
Webhook.joins(:rule).merge(rule)
end
|