Sha256: 428ba3130c9e33377e9dd813ad8ee2dfdef7f37438d7330b60929c417be00d61

Contents?: true

Size: 769 Bytes

Versions: 4

Compression:

Stored size: 769 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

4 entries across 4 versions & 1 rubygems

Version Path
ibm_db-5.5.0-x86-mingw32 test/models/membership.rb
ibm_db-5.4.1-x86-mingw32 test/models/membership.rb
ibm_db-5.4.0-x86-mingw32 test/models/membership.rb
ibm_db-5.3.2-x86-mingw32 test/models/membership.rb