Sha256: 0e12214be89f2b08e0ea75b3ebf3ce0fd37b5afc52fd17bf2d84045729ec27f0

Contents?: true

Size: 1.27 KB

Versions: 11

Compression:

Stored size: 1.27 KB

Contents

# Obsolescing 是废弃。
# #reason 是原因。
# #obsolesced 是被废弃的对象。
# #obsolescence_code 是废弃代码,OBSL 表示废弃, RCVR 表示恢复。

class Unidom::Action::Obsolescing < Unidom::Action::ApplicationRecord

  self.table_name = 'unidom_obsolescings'

  include Unidom::Common::Concerns::ModelExtension

  belongs_to :obsolescer_visitor, polymorphic: true
  belongs_to :obsolescer_party,   polymorphic: true
  belongs_to :obsolesced,         polymorphic: true
  belongs_to :reason,             class_name:  'Unidom::Action::Reason'

  scope :obsolesced_via, ->(obsolescer_visitor) { where obsolescer_visitor: obsolescer_visitor }
  scope :obsolesced_by,  ->(obsolescer_party)   { where obsolescer_party:   obsolescer_party   }
  scope :obsolesced_is,  ->(obsolesced)         { where obsolesced:         obsolesced         }
  scope :caused_by,      ->(reason)             { where reason_id:          to_id(reason)      }

  def self.obsolesce!(obsolesced: nil, obsolescer_visitor: nil, obsolescer_party: nil, reason: nil, obsolescence_code: 'OBSL', opened_at: Time.now)
    create! obsolesced: obsolesced, obsolescer_visitor: obsolescer_visitor, obsolescer_party: obsolescer_party, reason: reason, obsolescence_code: obsolescence_code, opened_at: opened_at
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
unidom-action-1.9.2 app/models/unidom/action/obsolescing.rb
unidom-action-1.9.1 app/models/unidom/action/obsolescing.rb
unidom-action-1.9 app/models/unidom/action/obsolescing.rb
unidom-action-1.8 app/models/unidom/action/obsolescing.rb
unidom-action-1.7 app/models/unidom/action/obsolescing.rb
unidom-action-1.6 app/models/unidom/action/obsolescing.rb
unidom-action-1.5 app/models/unidom/action/obsolescing.rb
unidom-action-1.4 app/models/unidom/action/obsolescing.rb
unidom-action-1.3 app/models/unidom/action/obsolescing.rb
unidom-action-1.2 app/models/unidom/action/obsolescing.rb
unidom-action-1.1 app/models/unidom/action/obsolescing.rb