Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
getfitter-core / app / models / concerns / core / trial_concern.rb
Size: Mime:
module Core
  # Provides helpers for handling trials.
  #
  # Intended to be mixed into Booking.
  module TrialConcern
    extend ActiveSupport::Concern

    def valid_for_trial?
      if event.organisation_venue.trial_available?
        previous_bookings = user.bookings.joins(:event).where(
          core_events: { organisation_venue_id: event.organisation_venue.id })

        return true if (previous_bookings - [self]).empty?
      end

      false
    end
  end
end