Sha256: 9d53086bb91dea2f34ffe0d76f5eda2525f8d71bfa934eea7c0f0cb99d868b53

Contents?: true

Size: 731 Bytes

Versions: 6

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

class Membership < ActiveRecord::Base
  enum type: %i(Membership CurrentMembership SuperMembership SelectedMembership TenantMembership)
  belongs_to :member
  belongs_to :club
end

class CurrentMembership < Membership
  belongs_to :member
  belongs_to :club
end

class SuperMembership < Membership
  belongs_to :member, -> { order("members.id DESC") }
  belongs_to :club
end

class SelectedMembership < Membership
  def self.default_scope
    select("'1' as foo")
  end
end

class TenantMembership < Membership
  cattr_accessor :current_member

  belongs_to :member
  belongs_to :club

  default_scope -> {
    if current_member
      where(member: current_member)
    else
      all
    end
  }
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ibm_db-5.5.0 test/models/membership.rb
ibm_db-5.4.1 test/models/membership.rb
ibm_db-5.4.0 test/models/membership.rb
ibm_db-5.3.2 test/models/membership.rb
ibm_db-5.3.1 test/models/membership.rb
ruby-on-quails-0.1.0 activerecord/test/models/membership.rb