Sha256: dbfd82dc442f4275f3b89d4b82eb1807630075d5c73d7d43d79180e480cdfcd0

Contents?: true

Size: 986 Bytes

Versions: 32

Compression:

Stored size: 986 Bytes

Contents

module Unidom::Action::Concerns::AsActed

  extend ActiveSupport::Concern

  included do |includer|

    has_many :actings, class_name: 'Unidom::Action::Acting', as: :acted

    def is_acted!(from: nil, thru: nil, due_to: nil, by: nil, via: nil, at: Time.now, action_code: 'C')
      actings.create! from_value: from, thru_value: thru, actor_visitor: via, actor_party: by, acted: self, reason: due_to, action_code: action_code, opened_at: at
    end

    def is_acted?(due_to: nil, by: nil, via: nil, at: Time.now, action_code: 'C')
      query = actings.acted_is      self
      query = query.acted_via       via         if via.present?
      query = query.acted_by        by          if by.present?
      query = query.caused_by       due_to      if due_to.present?
      query = query.action_coded_as action_code if action_code.present?
      query = query.valid_at        now: at     if at.present?
      query = query.alive.exists?
    end

  end

  module ClassMethods
  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
unidom-action-1.13 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.12 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.11.1 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.11 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.10 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.9.2 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.9.1 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.9 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.8 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.7 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.6 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.5 app/models/unidom/action/concerns/as_acted.rb