Sha256: e96dc5b7fa52409da3eeb3ccf83bfaa8660049ebbeed7e2100effd59ac47394b

Contents?: true

Size: 1.15 KB

Versions: 9

Compression:

Stored size: 1.15 KB

Contents

##
# As Inferior Post 是下级岗位的领域逻辑关注点。

module Unidom::Position::Concerns::AsInferiorPost

  extend ActiveSupport::Concern

  included do |includer|

    has_many :superior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :inferior_post, foreign_key: :inferior_post_id
    has_many :superior_posts,                     through:    :superior_post_reporting_structures,        source: :superior_post

    ##
    # 以下级岗位的身份与上级岗位 superior_post 建立岗位间的上下级汇报关系。
    # 主要汇报标志是 primary ,缺省为 true 。建立时间是 at ,缺省为当前时间。如:
    # rails_developer.report_to! project_manager, primary: false
    def report_to!(superior_post, at: Time.now, primary: true)
      superior_post_reporting_structures.superior_post_is(superior_post).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
    end

    def report_to?(superior_post, at: Time.now, primary: true)
      superior_post_reporting_structures.superior_post_is(superior_post).valid_at(now: at).alive.primary(primary).exists?
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
unidom-position-1.5.7 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5.6 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5.5 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5.4 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5.3 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5.2 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5.1 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.5 app/models/unidom/position/concerns/as_inferior_post.rb
unidom-position-1.4.5 app/models/unidom/position/concerns/as_inferior_post.rb