Class: MandateClaw::DSL::TemporalConstraint

Inherits:
Struct
  • Object
show all
Defined in:
lib/mandate_claw/dsl/temporal.rb

Overview

Represents a temporal constraint on an obligation or permission. Anchored to a named event or an absolute duration.

Used internally; surface API is:

obligation :pay, on: :buyer, within: 30.days

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#anchorObject

Returns the value of attribute anchor

Returns:

  • (Object)

    the current value of anchor



11
12
13
# File 'lib/mandate_claw/dsl/temporal.rb', line 11

def anchor
  @anchor
end

#durationObject

Returns the value of attribute duration

Returns:

  • (Object)

    the current value of duration



11
12
13
# File 'lib/mandate_claw/dsl/temporal.rb', line 11

def duration
  @duration
end

Instance Method Details

#breached?(base_time, now = Time.current) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mandate_claw/dsl/temporal.rb', line 16

def breached?(base_time, now = Time.current)
  now > deadline_from(base_time)
end

#deadline_from(base_time) ⇒ Object



12
13
14
# File 'lib/mandate_claw/dsl/temporal.rb', line 12

def deadline_from(base_time)
  base_time + duration
end