Sha256: daaf5cbe5f4fb6c9858c4a1ab668b9590ea3291768b605192f1d53fcfd397e65

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

module Camaraderie
  module User
    extend ActiveSupport::Concern

    included do
      # Associations
      has_many :memberships, dependent: :destroy, foreign_key: :user_id, class_name: 'Membership', inverse_of: :user
      has_many :organizations, through: :memberships, class_name: Camaraderie.organization_class, inverse_of: :users

      Camaraderie.membership_types.each do |type|
        class_eval <<-RUBY, __FILE__, __LINE__ + 1
          def #{type}_of?(organization)
            !!memberships.#{type.pluralize}.where(organization_id: organization.id).exists?
          end
        RUBY
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
camaraderie-0.2.1 lib/camaraderie/user.rb
camaraderie-0.2 lib/camaraderie/user.rb