Sha256: 0bad02d8131d7ed91d453afcdd2e2cdffa295cb96648d75e201b6af98651a343

Contents?: true

Size: 634 Bytes

Versions: 2

Compression:

Stored size: 634 Bytes

Contents

module Tramway::Partner::Scopes
  extend ActiveSupport::Concern

  included do
    ::Tramway::Partner::Partnership.partnership_type.values.each do |partnership_type|
      define_method partnership_type.pluralize.to_sym do
        query = <<-SQL
        tramway_partner_partnerships.partnership_type = '#{partnership_type}'
        AND tramway_partner_partnerships.partner_id = '#{id}'
        AND tramway_partner_partnerships.state = 'active'
        AND tramway_partner_partnerships.partner_type = '#{self.class.name}'
        SQL
        Tramway::Partner::Organization.joins(:partnerships).where(query)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tramway-partner-1.0.3.1 lib/tramway/partner/scopes.rb
tramway-partner-1.0.3 lib/tramway/partner/scopes.rb