Class: Parse::Access::Decision

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/access.rb

Overview

An access answer together with the evidence behind it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, operation:, reasons: [], details: {}) ⇒ Decision

Returns a new instance of Decision.



23
24
25
26
27
28
29
# File 'lib/parse/access.rb', line 23

def initialize(status:, operation:, reasons: [], details: {})
  @status = status.to_sym
  @operation = operation.to_sym
  @reasons = Array(reasons).compact.map(&:to_sym).uniq.freeze
  @details = details.dup.freeze
  freeze
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



21
22
23
# File 'lib/parse/access.rb', line 21

def details
  @details
end

#operationObject (readonly)

Returns the value of attribute operation.



21
22
23
# File 'lib/parse/access.rb', line 21

def operation
  @operation
end

#reasonsObject (readonly)

Returns the value of attribute reasons.



21
22
23
# File 'lib/parse/access.rb', line 21

def reasons
  @reasons
end

#statusObject (readonly)

Returns the value of attribute status.



21
22
23
# File 'lib/parse/access.rb', line 21

def status
  @status
end

Instance Method Details

#allowed?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/parse/access.rb', line 31

def allowed?
  status == :allowed
end

#denied?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/parse/access.rb', line 35

def denied?
  status == :denied
end

#to_hObject



43
44
45
# File 'lib/parse/access.rb', line 43

def to_h
  { status: status, operation: operation, reasons: reasons, details: details }
end

#unknown?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/parse/access.rb', line 39

def unknown?
  status == :unknown
end