Class: Tokite::Rule
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Tokite::Rule
- Defined in:
- app/models/tokite/rule.rb
Constant Summary collapse
- INVALID_CHANNEL_CHARS =
[" ", ","]
Instance Attribute Summary collapse
-
#search_query ⇒ Object
readonly
Returns the value of attribute search_query.
Class Method Summary collapse
-
.matched_rules(event) ⇒ Object
TODO: Performance.
Instance Method Summary collapse
- #match?(event) ⇒ Boolean
- #rule_name_link ⇒ Object
- #slack_attachment_fallback ⇒ Object
- #slack_attachment_text ⇒ Object
- #user_link ⇒ Object
Instance Attribute Details
#search_query ⇒ Object (readonly)
Returns the value of attribute search_query.
3 4 5 |
# File 'app/models/tokite/rule.rb', line 3 def search_query @search_query end |
Class Method Details
.matched_rules(event) ⇒ Object
TODO: Performance
17 18 19 20 21 |
# File 'app/models/tokite/rule.rb', line 17 def self.matched_rules(event) Rule.all.to_a.select do |rule| rule.match?(event) end end |
Instance Method Details
#match?(event) ⇒ Boolean
27 28 29 |
# File 'app/models/tokite/rule.rb', line 27 def match?(event) search_query.match?(event.fields) end |
#rule_name_link ⇒ Object
39 40 41 |
# File 'app/models/tokite/rule.rb', line 39 def rule_name_link "<#{Tokite::Engine.routes.url_helpers.edit_rule_url(self)}|#{name}>" end |
#slack_attachment_fallback ⇒ Object
31 32 33 |
# File 'app/models/tokite/rule.rb', line 31 def "#{name} by #{user.name}" end |
#slack_attachment_text ⇒ Object
35 36 37 |
# File 'app/models/tokite/rule.rb', line 35 def "#{rule_name_link} (#{user_link}) " end |