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.17.13 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.14 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.12 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.11 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.10 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.9 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.8 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.7 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.6 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.5 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.4 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.3 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.2 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17.1 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.17 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.16.2 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.16.1 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.16 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.15 app/models/unidom/action/concerns/as_acted.rb
unidom-action-1.14 app/models/unidom/action/concerns/as_acted.rb