module Law::Laws::Actions

Public Instance Methods

define_action(*input_actions, enforces: nil) click to toggle source
# File lib/law/laws/actions.rb, line 37
def define_action(*input_actions, enforces: nil)
  raise ArgumentError, "invalid statute: #{enforces}" unless enforceable?(enforces)

  input_actions.each do |action|
    actions[action] = enforces
    enforces.try(:enforced_by, self, action)
    define_judgement_predicates_for_action(action)
  end
end
enforceable?(enforces) click to toggle source
# File lib/law/laws/actions.rb, line 47
def enforceable?(enforces)
  enforces.nil? || enforces.respond_to?(:enforced_by)
end
inherited(base) click to toggle source
Calls superclass method
# File lib/law/laws/actions.rb, line 17
def inherited(base)
  base.actions = actions.dup
  base.revoked_actions = revoked_actions.dup
  super
end
revoke_action(*input_actions) click to toggle source
# File lib/law/laws/actions.rb, line 33
def revoke_action(*input_actions)
  input_actions.each { |action| revoked_actions[action] = true }
end
revoked_action?(action) click to toggle source
# File lib/law/laws/actions.rb, line 23
def revoked_action?(action)
  revoked_actions[action].present?
end
statute_for_action?(action) click to toggle source
# File lib/law/laws/actions.rb, line 27
def statute_for_action?(action)
  actions[action].present?
end