Class: Email::ContentRules::Rule
- Inherits:
-
Data
- Object
- Data
- Email::ContentRules::Rule
- Defined in:
- app/services/email/content_rules.rb
Overview
A single design rule. severity: :warn (advisory, default) or :error (blocks save).
Instance Attribute Summary collapse
-
#applies_to ⇒ Object
readonly
Returns the value of attribute applies_to.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#validate ⇒ Object
readonly
Returns the value of attribute validate.
Instance Method Summary collapse
- #call(html) ⇒ Object
-
#initialize(name:, applies_to:, validate:, severity: :warn) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(name:, applies_to:, validate:, severity: :warn) ⇒ Rule
Returns a new instance of Rule.
33 |
# File 'app/services/email/content_rules.rb', line 33 def initialize(name:, applies_to:, validate:, severity: :warn) = super |
Instance Attribute Details
#applies_to ⇒ Object (readonly)
Returns the value of attribute applies_to
32 33 34 |
# File 'app/services/email/content_rules.rb', line 32 def applies_to @applies_to end |
#name ⇒ Object (readonly)
Returns the value of attribute name
32 33 34 |
# File 'app/services/email/content_rules.rb', line 32 def name @name end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity
32 33 34 |
# File 'app/services/email/content_rules.rb', line 32 def severity @severity end |
#validate ⇒ Object (readonly)
Returns the value of attribute validate
32 33 34 |
# File 'app/services/email/content_rules.rb', line 32 def validate @validate end |
Instance Method Details
#call(html) ⇒ Object
35 36 37 |
# File 'app/services/email/content_rules.rb', line 35 def call(html) Array(validate.call(html)).compact.map { |msg| { rule: name, message: msg.to_s, severity: severity } } end |