Sha256: 494378f6cebea423f026c6e630387eec7cfc273b362c76b56247cf4e58481344

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module Unidom::Action::Concerns::AsActorParty

  extend  ActiveSupport::Concern
  include Unidom::Common::Concerns::ArgumentValidation

  included do |includer|

    has_many :acted_actings, class_name: 'Unidom::Action::Acting', as: :actor_party

    def act!(on: nil, from: nil, thru: nil, due_to: nil, via: nil, at: Time.now, action_code: 'C')

      assert_present! :on,          on
      assert_present! :via,         via
      assert_present! :at,          at
      assert_present! :action_code, action_code

      acted_actings.create! acted: on, from_value: from, thru_value: thru, reason: due_to, actor_visitor: via, opened_at: at, action_code: action_code

    end

    def act?(on: nil, due_to: nil, via: nil, at: Time.now, action_code: 'C')
      query = acted_actings
      query = query.acted_is        on          if on.present?
      query = query.acted_via       via         if via.present?
      query = query.action_coded_as action_code if action_code.present?
      query = query.valid_at        now: at     if at.present?
      query = query.caused_by       due_to      if due_to.present?
      query.alive.exists?
    end

  end

  module ClassMethods
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unidom-action-2.0 app/models/unidom/action/concerns/as_actor_party.rb
unidom-action-1.17.18 app/models/unidom/action/concerns/as_actor_party.rb
unidom-action-1.17.17 app/models/unidom/action/concerns/as_actor_party.rb
unidom-action-1.17.16 app/models/unidom/action/concerns/as_actor_party.rb