Class: MtaSts::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/mta_sts/result.rb

Overview

status = what this lookup learned; policy = what to honour (§5.1)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commentObject (readonly)

Returns the value of attribute comment.



4
5
6
# File 'lib/mta_sts/result.rb', line 4

def comment
  @comment
end

#policyObject (readonly)

Returns the value of attribute policy.



4
5
6
# File 'lib/mta_sts/result.rb', line 4

def policy
  @policy
end

#statusObject (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

Returns:

  • (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

Returns:

  • (Boolean)


27
28
29
# File 'lib/mta_sts/result.rb', line 27

def enforce?
  policy&.enforce? || false
end

#found?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/mta_sts/result.rb', line 10

def found?
  status == "found"
end

#inspectObject



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?)

Returns:

  • (Boolean)


15
16
17
# File 'lib/mta_sts/result.rb', line 15

def no_record?
  status == "none"
end

#permerror?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/mta_sts/result.rb', line 23

def permerror?
  status == "permerror"
end

#temperror?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/mta_sts/result.rb', line 19

def temperror?
  status == "temperror"
end

#testing?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/mta_sts/result.rb', line 31

def testing?
  policy&.testing? || false
end