Class: MtaSts::Result
- Inherits:
-
Object
- Object
- MtaSts::Result
- Defined in:
- lib/mta_sts/result.rb
Overview
status = what this lookup learned; policy = what to honour (§5.1)
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #allows?(host) ⇒ Boolean
- #enforce? ⇒ Boolean
- #found? ⇒ Boolean
-
#initialize(status:, policy: nil, comment: nil) ⇒ Result
constructor
A new instance of Result.
- #inspect ⇒ Object
-
#no_record? ⇒ Boolean
"no TXT this time" — not "no policy applies" (see Policy#none?).
- #permerror? ⇒ Boolean
- #temperror? ⇒ Boolean
- #testing? ⇒ Boolean
Constructor Details
#initialize(status:, policy: nil, comment: nil) ⇒ Result
Returns a new instance of Result.
6 7 8 |
# File 'lib/mta_sts/result.rb', line 6 def initialize(status:, policy: nil, comment: nil) @status, @policy, @comment = status, policy, comment end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
4 5 6 |
# File 'lib/mta_sts/result.rb', line 4 def comment @comment end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
4 5 6 |
# File 'lib/mta_sts/result.rb', line 4 def policy @policy end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/mta_sts/result.rb', line 4 def status @status end |
Instance Method Details
#allows?(host) ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/mta_sts/result.rb', line 35 def allows?(host) if policy policy.allows?(host) else true end end |
#enforce? ⇒ Boolean
27 28 29 |
# File 'lib/mta_sts/result.rb', line 27 def enforce? policy&.enforce? || false end |
#found? ⇒ Boolean
10 11 12 |
# File 'lib/mta_sts/result.rb', line 10 def found? status == "found" end |
#inspect ⇒ Object
43 44 45 |
# File 'lib/mta_sts/result.rb', line 43 def inspect "#<#{self.class.name} status: #{status.inspect}, policy: #{policy.inspect}, comment: #{comment.inspect}>" end |
#no_record? ⇒ Boolean
"no TXT this time" — not "no policy applies" (see Policy#none?)
15 16 17 |
# File 'lib/mta_sts/result.rb', line 15 def no_record? status == "none" end |
#permerror? ⇒ Boolean
23 24 25 |
# File 'lib/mta_sts/result.rb', line 23 def permerror? status == "permerror" end |
#temperror? ⇒ Boolean
19 20 21 |
# File 'lib/mta_sts/result.rb', line 19 def temperror? status == "temperror" end |
#testing? ⇒ Boolean
31 32 33 |
# File 'lib/mta_sts/result.rb', line 31 def testing? policy&.testing? || false end |