Class: Law::Judgement
- Inherits:
-
Spicerack::RootObject
- Object
- Spicerack::RootObject
- Law::Judgement
- Defined in:
- lib/law/judgement.rb
Instance Attribute Summary collapse
-
#applied_regulations ⇒ Object
readonly
Returns the value of attribute applied_regulations.
-
#petition ⇒ Object
readonly
Returns the value of attribute petition.
-
#violations ⇒ Object
readonly
Returns the value of attribute violations.
Class Method Summary collapse
Instance Method Summary collapse
- #adjudicated? ⇒ Boolean
- #authorized? ⇒ Boolean
-
#initialize(petition) ⇒ Judgement
constructor
A new instance of Judgement.
- #judge ⇒ Object
- #judge! ⇒ Object
Constructor Details
#initialize(petition) ⇒ Judgement
Returns a new instance of Judgement.
20 21 22 23 24 |
# File 'lib/law/judgement.rb', line 20 def initialize(petition) @petition = petition @violations = [] @applied_regulations = [] end |
Instance Attribute Details
#applied_regulations ⇒ Object (readonly)
Returns the value of attribute applied_regulations.
16 17 18 |
# File 'lib/law/judgement.rb', line 16 def applied_regulations @applied_regulations end |
#petition ⇒ Object (readonly)
Returns the value of attribute petition.
16 17 18 |
# File 'lib/law/judgement.rb', line 16 def petition @petition end |
#violations ⇒ Object (readonly)
Returns the value of attribute violations.
16 17 18 |
# File 'lib/law/judgement.rb', line 16 def violations @violations end |
Class Method Details
.judge(petition) ⇒ Object
11 12 13 |
# File 'lib/law/judgement.rb', line 11 def judge(petition) new(petition).judge end |
.judge!(petition) ⇒ Object
7 8 9 |
# File 'lib/law/judgement.rb', line 7 def judge!(petition) new(petition).judge! end |
Instance Method Details
#adjudicated? ⇒ Boolean
26 27 28 |
# File 'lib/law/judgement.rb', line 26 def adjudicated? applied_regulations.present? end |
#authorized? ⇒ Boolean
30 31 32 |
# File 'lib/law/judgement.rb', line 30 def adjudicated? && violations.blank? end |
#judge ⇒ Object
34 35 36 37 38 39 |
# File 'lib/law/judgement.rb', line 34 def judge judge! rescue NotAuthorizedError => exception error :not_authorized, exception: exception false end |
#judge! ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/law/judgement.rb', line 41 def judge! raise AlreadyJudgedError if adjudicated? if statute&.unregulated? @applied_regulations = [ nil ] return true end ensure_jurisdiction reckon! true end |