Sha256: e70c868e376313c71e34d6b7bcc2eda30f6649db0b52bfc9fb3ec445ec034fb7

Contents?: true

Size: 842 Bytes

Versions: 3

Compression:

Stored size: 842 Bytes

Contents

# Acting 是行为记录。
# #reason 是原因。
# #acted 是被操作的对象。
# #action_code 是行为代码,C: create, R: read, U: update, D: destroy。

class Unidom::Action::Acting < Unidom::Action::ApplicationRecord

  self.table_name = 'unidom_actings'

  include Unidom::Common::Concerns::ModelExtension

  belongs_to :actor_visitor, polymorphic: true
  belongs_to :actor_party,   polymorphic: true
  belongs_to :acted,         polymorphic: true
  belongs_to :reason,        class_name:  'Unidom::Action::Reason'

  scope :acted_via, ->(actor_visitor) { where actor_visitor: actor_visitor }
  scope :acted_by,  ->(actor_party)   { where actor_party:   actor_party   }
  scope :acted_is,  ->(acted)         { where acted:         acted         }
  scope :caused_by, ->(reason)        { where reason_id:     to_id(reason) }

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unidom-action-1.3 app/models/unidom/action/acting.rb
unidom-action-1.2 app/models/unidom/action/acting.rb
unidom-action-1.1 app/models/unidom/action/acting.rb