repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/search_index_model_common.rb | app/models/concerns/search_index_model_common.rb | # frozen_string_literal: true
module SearchIndexModelCommon
extend ActiveSupport::Concern
class_methods do
def search_fields
@_search_fields ||= mappings.to_hash[:properties].keys.map(&:to_s)
end
end
def as_indexed_json(options = {})
fields = options[:only] || self.class.search_fields
f... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/attribute_blockable.rb | app/models/concerns/attribute_blockable.rb | # frozen_string_literal: true
# AttributeBlockable provides a flexible system for checking if model attributes
# are blocked via the BlockedObject system, with support for efficient N+1 query
# prevention through eager loading.
#
# == Basic Usage
#
# To make an attribute blockable, use the +attr_blockable+ class metho... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/secure_external_id.rb | app/models/concerns/secure_external_id.rb | # frozen_string_literal: true
# A concern to generate and resolve secure, expiring, encrypted, URL-safe tokens
# that represent a model instance. It supports key rotation.
#
# Configuration:
# This module requires configuration in your config/credentials.yml.enc or environment variables via GlobalConfig.
# The configu... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/json_data.rb | app/models/concerns/json_data.rb | # frozen_string_literal: true
# Mixin for modules that contain a `json_data` field. Adds functions that
# standardize how data is stored within the `json_data` field, and what happens
# if the data within is not present or blank.
#
# All functions are safe to call when `json_data` is nil and it does not need
# to be i... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/with_filtering.rb | app/models/concerns/with_filtering.rb | # frozen_string_literal: true
module WithFiltering
extend ActiveSupport::Concern
include CurrencyHelper, JsonData
AUDIENCE_TYPE = "audience"
SELLER_TYPE = "seller"
PRODUCT_TYPE = "product"
VARIANT_TYPE = "variant"
FOLLOWER_TYPE = "follower"
AFFILIATE_TYPE = "affiliate"
ABANDONED_CART_TYPE = "abandon... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/max_purchase_count.rb | app/models/concerns/max_purchase_count.rb | # frozen_string_literal: true
module MaxPurchaseCount
extend ActiveSupport::Concern
MAX_PURCHASE_COUNT_RANGE = (0 .. 10_000_000)
included do
before_validation :constrain_max_purchase_count_within_range
validates_numericality_of :max_purchase_count, in: MAX_PURCHASE_COUNT_RANGE, allow_nil: true
end
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/transactional_attribute_change_tracker.rb | app/models/concerns/transactional_attribute_change_tracker.rb | # frozen_string_literal: true
# Tracks all the attributes that were changed in a transaction,
# and makes them available in `#attributes_committed` when the transaction is committed.
# This module exists because `previous_changes` only contains the attributes that were changed in the last `save`,
# if the record was n... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/rich_contents.rb | app/models/concerns/rich_contents.rb | # frozen_string_literal: true
module RichContents
extend ActiveSupport::Concern
included do
has_many :rich_contents, as: :entity
has_many :alive_rich_contents, -> { alive }, class_name: "RichContent", as: :entity
end
def rich_content_folder_name(folder_id)
return if folder_id.blank?
folder =... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/unused_columns.rb | app/models/concerns/unused_columns.rb | # frozen_string_literal: true
# This module allows marking certain columns as unused on a model.
# For large tables, removing columns can be an expensive operation. It is often preferable to collect
# multiple columns and remove them in a batch.
# This serves as a temporary alternative to `self.ignored_columns`, which... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/versionable.rb | app/models/concerns/versionable.rb | # frozen_string_literal: true
# Requires has_paper_trail on the model
#
module Versionable
extend ActiveSupport::Concern
# Reasonable limit of version records to query
LIMIT = 100
VersionInfoStruct = Struct.new(:created_at, :changes)
# It returns a collection of VersionInfoStruct objects that contain chan... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/charge_processable.rb | app/models/concerns/charge_processable.rb | # frozen_string_literal: true
module ChargeProcessable
def stripe_charge_processor?
charge_processor_id == StripeChargeProcessor.charge_processor_id
end
def paypal_charge_processor?
charge_processor_id == PaypalChargeProcessor.charge_processor_id
end
def braintree_charge_processor?
charge_proce... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/streamable.rb | app/models/concerns/streamable.rb | # frozen_string_literal: true
module Streamable
extend ActiveSupport::Concern
included do
has_many :transcoded_videos, as: :streamable
end
def attempt_to_transcode?(allowed_when_processing: false)
# Don't transcode if another transcoding job is already pending for this particular video.
return fa... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/timestamp_state_fields.rb | app/models/concerns/timestamp_state_fields.rb | # frozen_string_literal: true
# Implements ActiveRecord state fields based on timestamp columns.
#
# Requires a column to be named `property_at`, e.g., `verified_at`.
#
# `state` method uses reverse order of states to determine priority. E.g., it
# checks the last state in the fields first to determine if the object ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/installment/searchable.rb | app/models/concerns/installment/searchable.rb | # frozen_string_literal: true
module Installment::Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include SearchIndexModelCommon
include ElasticsearchModelAsyncCallbacks
index_name "installments"
settings number_of_shards: 1, number_of_replicas: 0, index: {
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/native_type_templates.rb | app/models/concerns/product/native_type_templates.rb | # frozen_string_literal: true
module Product::NativeTypeTemplates
extend ActiveSupport::Concern
DEFAULT_ATTRIBUTES_FOR_TYPE = {
podcast: [
{ name: "Episodes", value: "" },
{ name: "Total length", value: "" }
],
ebook: [
{ name: "Pages", value: "" }
],
audiobook: [
{ nam... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/taxonomies.rb | app/models/concerns/product/taxonomies.rb | # frozen_string_literal: true
module Product::Taxonomies
extend ActiveSupport::Concern
include Purchase::Searchable::ProductCallbacks
included do
belongs_to :taxonomy, optional: true
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/bundles_marketing.rb | app/models/concerns/product/bundles_marketing.rb | # frozen_string_literal: true
module Product::BundlesMarketing
YEAR_BUNDLE = "year"
BEST_SELLING_BUNDLE = "best_selling"
EVERYTHING_BUNDLE = "everything"
BUNDLE_NAMES = {
YEAR_BUNDLE => "#{1.year.ago.year} Bundle",
BEST_SELLING_BUNDLE => "Best Selling Bundle",
EVERYTHING_BUNDLE => "Everything Bund... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/as_json.rb | app/models/concerns/product/as_json.rb | # frozen_string_literal: true
module Product::AsJson
extend ActiveSupport::Concern
included do
alias super_as_json as_json
end
def as_json(options = {})
return super(options) if options.delete(:original)
return as_json_for_admin_info if options.delete(:admin_info)
return as_json_for_api(optio... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/structured_data.rb | app/models/concerns/product/structured_data.rb | # frozen_string_literal: true
module Product::StructuredData
extend ActiveSupport::Concern
include ActionView::Helpers::SanitizeHelper
def structured_data
return {} unless native_type == Link::NATIVE_TYPE_EBOOK
data = {
"@context" => "https://schema.org",
"@type" => "Book",
"name" => ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/sorting.rb | app/models/concerns/product/sorting.rb | # frozen_string_literal: true
module Product::Sorting
extend ActiveSupport::Concern
ES_SORT_KEYS = ["display_price_cents", "is_recommendable"]
SQL_SORT_KEYS = ["name", "successful_sales_count", "status", "taxonomy", "display_product_reviews", "revenue", "cut"]
SORT_KEYS = ES_SORT_KEYS + SQL_SORT_KEYS
SORT_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/staff_picked.rb | app/models/concerns/product/staff_picked.rb | # frozen_string_literal: true
module Product::StaffPicked
extend ActiveSupport::Concern
def staff_picked?
return false if staff_picked_product.blank?
staff_picked_product.not_deleted?
end
alias_method :staff_picked, :staff_picked?
def staff_picked_at
return if staff_picked_product.blank? || st... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/layout.rb | app/models/concerns/product/layout.rb | # frozen_string_literal: true
module Product::Layout
PROFILE = "profile"
DISCOVER = "discover"
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/product/tags.rb | app/models/concerns/product/tags.rb | # frozen_string_literal: true
module Product::Tags
extend ActiveSupport::Concern
included do
has_many :product_taggings, foreign_key: :product_id, dependent: :destroy
has_many :tags, through: :product_taggings
scope :with_tags, lambda { |tag_names|
if tag_names.present? && tag_names.any?
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/recommendation_type.rb | app/models/concerns/user/recommendation_type.rb | # frozen_string_literal: true
module User::RecommendationType
TYPES = [
"no_recommendations",
"own_products",
"gumroad_affiliates_products",
"directly_affiliated_products"
].freeze
TYPES.each do |type|
self.const_set(type.upcase, type)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/social_apple.rb | app/models/concerns/user/social_apple.rb | # frozen_string_literal: true
module User::SocialApple
extend ActiveSupport::Concern
class_methods do
def find_for_apple_auth(authorization_code:, app_type:)
email = verified_apple_id_email(authorization_code:, app_type:)
return if email.blank?
User.find_by(email:)
end
private
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/comments.rb | app/models/concerns/user/comments.rb | # frozen_string_literal: true
module User::Comments
extend ActiveSupport::Concern
def add_payout_note(content:)
comments.create!(
content:,
author_id: GUMROAD_ADMIN_ID,
comment_type: Comment::COMMENT_TYPE_PAYOUT_NOTE
)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/vip_creator.rb | app/models/concerns/user/vip_creator.rb | # frozen_string_literal: true
module User::VipCreator
extend ActiveSupport::Concern
def vip_creator?
recent_gross_sales_cents > 5_000_00
end
private
def recent_gross_sales_cents
search_params = {
seller: self,
state: Purchase::CHARGED_SUCCESS_STATES,
exclude_giftees: tru... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/direct_affiliates.rb | app/models/concerns/user/direct_affiliates.rb | # frozen_string_literal: true
module User::DirectAffiliates
extend ActiveSupport::Concern
included do
has_many :direct_affiliates, foreign_key: :seller_id, class_name: "DirectAffiliate"
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/taxation.rb | app/models/concerns/user/taxation.rb | # frozen_string_literal: true
module User::Taxation
extend ActiveSupport::Concern
include Compliance
MIN_SALE_AMOUNT_FOR_1099_K_FEDERAL_FILING = 5_000 * 100
# Ref https://docs.stripe.com/connect/1099-K for state filing thresholds
MIN_SALE_AMOUNTS_FOR_1099_K_STATE_FILINGS = {
"AL" => MIN_SALE_AMOUNT_FOR_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/low_balance_fraud_check.rb | app/models/concerns/user/low_balance_fraud_check.rb | # frozen_string_literal: true
module User::LowBalanceFraudCheck
extend ActiveSupport::Concern
LOW_BALANCE_THRESHOLD = -100_00 # USD -100
private_constant :LOW_BALANCE_THRESHOLD
LOW_BALANCE_PROBATION_WAIT_TIME = 2.months
private_constant :LOW_BALANCE_PROBATION_WAIT_TIME
LOW_BALANCE_FRAUD_CHECK_AUTHOR_NAM... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/stripe_connect.rb | app/models/concerns/user/stripe_connect.rb | # frozen_string_literal: true
module User::StripeConnect
extend ActiveSupport::Concern
class_methods do
def find_or_create_for_stripe_connect_account(data)
return nil if data.blank?
user = MerchantAccount.where(charge_processor_merchant_id: data["uid"]).alive
.find { |ma| ma.is_a... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/as_json.rb | app/models/concerns/user/as_json.rb | # frozen_string_literal: true
module User::AsJson
extend ActiveSupport::Concern
def as_json(options = {})
result =
if options[:internal_use] || valid_api_scope?(options)
super(only: %i[name bio twitter_handle currency_type], methods: options[:methods], include: options[:include])
.merg... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/purchases.rb | app/models/concerns/user/purchases.rb | # frozen_string_literal: true
module User::Purchases
extend ActiveSupport::Concern
def transfer_purchases!(new_email:)
new_user = User.find_by!(email: new_email)
purchases = Purchase.where(email:)
transaction do
purchases.find_each do |purchase|
purchase.email = new_email
purcha... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/mailer_level.rb | app/models/concerns/user/mailer_level.rb | # frozen_string_literal: true
module User::MailerLevel
extend ActiveSupport::Concern
MAILER_LEVEL_REDIS_EXPIRY = 1.week
def mailer_level
# Use Memcached cache to reduce the number of queries to Redis
Rails.cache.fetch("creator_mailer_level_#{id}", expires_in: 2.days) do
level_from_redis = mailer_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/social_google.rb | app/models/concerns/user/social_google.rb | # frozen_string_literal: true
module User::SocialGoogle
extend ActiveSupport::Concern
def google_picture_url(data)
return nil if data["info"]["image"].nil? || data["info"]["image"].empty?
pic_url = data["info"]["image"]
# Replacing all instances of "s96-c" in the string with "s400-c" to get a larger ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/team.rb | app/models/concerns/user/team.rb | # frozen_string_literal: true
module User::Team
extend ActiveSupport::Concern
included do
has_many :user_memberships, class_name: "TeamMembership", foreign_key: :user_id
has_many :seller_memberships, class_name: "TeamMembership", foreign_key: :seller_id
has_many :team_invitations, foreign_key: :seller... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/followers.rb | app/models/concerns/user/followers.rb | # frozen_string_literal: true
module User::Followers
extend ActiveSupport::Concern
included do
has_many :followers, foreign_key: "followed_id"
end
def follower_by_email(email)
Follower.active.find_by(followed_id: id, email:)
end
def followed_by?(email)
follower_by_email(email).present?
end... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/affiliated_products.rb | app/models/concerns/user/affiliated_products.rb | # frozen_string_literal: true
module User::AffiliatedProducts
extend ActiveSupport::Concern
def directly_affiliated_products(alive: true)
scope = Link.with_direct_affiliates
scope = scope.merge(DirectAffiliate.alive).alive if alive
scope.for_affiliate_user(id)
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/user/social_google_mobile.rb | app/models/concerns/user/social_google_mobile.rb | # frozen_string_literal: true
module User::SocialGoogleMobile
extend ActiveSupport::Concern
class_methods do
def find_for_google_mobile_auth(google_id_token:)
email = email_from_google_id_token(google_id_token:)
return if email.blank?
User.find_by(email:)
end
private
def emai... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/follower/audience_member.rb | app/models/concerns/follower/audience_member.rb | # frozen_string_literal: true
module Follower::AudienceMember
extend ActiveSupport::Concern
included do
after_save :update_audience_member_details
after_destroy :remove_from_audience_member_details
end
def should_be_audience_member?
confirmed_at.present? && EmailFormatValidator.valid?(email)
en... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/affiliate/cookies.rb | app/models/concerns/affiliate/cookies.rb | # frozen_string_literal: true
module Affiliate::Cookies
extend ActiveSupport::Concern
AFFILIATE_COOKIE_NAME_PREFIX = "_gumroad_affiliate_id_"
class_methods do
def by_cookies(cookies)
in_order_of(:id, ids_from_cookies(cookies))
end
def ids_from_cookies(cookies)
cookies
.sort_by ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/affiliate/audience_member.rb | app/models/concerns/affiliate/audience_member.rb | # frozen_string_literal: true
module Affiliate::AudienceMember
extend ActiveSupport::Concern
included do
after_save :update_audience_member_details
after_destroy :remove_from_audience_member_details
end
def update_audience_member_with_added_product(product_or_id)
return unless persisted? && type ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/affiliate/destination_url_validations.rb | app/models/concerns/affiliate/destination_url_validations.rb | # frozen_string_literal: true
module Affiliate::DestinationUrlValidations
extend ActiveSupport::Concern
included do
validate :destination_url_validation
private
def destination_url_validation
return if destination_url.blank?
errors.add(:base, "The destination url you entered is inv... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/affiliate/basis_points_validations.rb | app/models/concerns/affiliate/basis_points_validations.rb | # frozen_string_literal: true
module Affiliate::BasisPointsValidations
extend ActiveSupport::Concern
MIN_AFFILIATE_BASIS_POINTS = 100 # 1%
MAX_AFFILIATE_BASIS_POINTS = 7500 # 75%
included do
private
def affiliate_basis_points_must_fall_in_an_acceptable_range
return if affiliate_basis_points... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/affiliate/sorting.rb | app/models/concerns/affiliate/sorting.rb | # frozen_string_literal: true
module Affiliate::Sorting
extend ActiveSupport::Concern
SORT_KEYS = ["affiliate_user_name", "products", "fee_percent", "volume_cents"]
SORT_KEYS.each do |key|
const_set(key.upcase, key)
end
class_methods do
def sorted_by(key: nil, direction: nil)
direction = dir... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/upsell/sorting.rb | app/models/concerns/upsell/sorting.rb | # frozen_string_literal: true
module Upsell::Sorting
extend ActiveSupport::Concern
SORT_KEYS = ["name", "revenue", "uses", "status"]
SORT_KEYS.each do |key|
const_set(key.upcase, key)
end
class_methods do
def sorted_by(key: nil, direction: nil)
direction = direction == "desc" ? "desc" : "asc... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/offer_code/sorting.rb | app/models/concerns/offer_code/sorting.rb | # frozen_string_literal: true
module OfferCode::Sorting
extend ActiveSupport::Concern
SORT_KEYS = ["name", "revenue", "uses", "term"]
SORT_KEYS.each do |key|
const_set(key.upcase, key)
end
class_methods do
def sorted_by(key: nil, direction: nil)
direction = direction == "desc" ? "desc" : "as... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/charge/disputable.rb | app/models/concerns/charge/disputable.rb | # frozen_string_literal: true
module Charge::Disputable
extend ActiveSupport::Concern
include CurrencyHelper
included do
has_one :dispute
def charge_processor
is_a?(Charge) ? processor : charge_processor_id
end
def charge_processor_transaction_id
is_a?(Charge) ? processor_transacti... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/charge/chargeable.rb | app/models/concerns/charge/chargeable.rb | # frozen_string_literal: true
module Charge::Chargeable
class << self
def find_by_stripe_event(event)
chargeable = nil
if event.charge_reference.to_s.starts_with?(Charge::COMBINED_CHARGE_PREFIX)
chargeable ||= Charge.where(id: event.charge_reference.sub(Charge::COMBINED_CHARGE_PREFIX, "")).l... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/charge/refundable.rb | app/models/concerns/charge/refundable.rb | # frozen_string_literal: true
module Charge::Refundable
extend ActiveSupport::Concern
def handle_event_refund_updated!(event)
stripe_refund_id = event.refund_id
db_refunds = Refund.where(processor_refund_id: stripe_refund_id)
if db_refunds.present?
db_refunds.each do |db_refund|
db_refu... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/video_file/has_thumbnail.rb | app/models/concerns/video_file/has_thumbnail.rb | # frozen_string_literal: true
module VideoFile::HasThumbnail
extend ActiveSupport::Concern
THUMBNAIL_SUPPORTED_CONTENT_TYPES = /jpeg|gif|png|jpg/i
THUMBNAIL_MAXIMUM_SIZE = 5.megabytes
included do
has_one_attached :thumbnail do |attachable|
attachable.variant :preview, resize_to_limit: [1280, 720], ... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/payment/failure_reason.rb | app/models/concerns/payment/failure_reason.rb | # frozen_string_literal: true
module Payment::FailureReason
extend ActiveSupport::Concern
CANNOT_PAY = "cannot_pay"
DEBIT_CARD_LIMIT = "debit_card_limit"
INSUFFICIENT_FUNDS = "insufficient_funds"
PAYPAL_MASS_PAY = {
"PAYPAL 1000" => "Unknown error",
"PAYPAL 1001" => "Receiver's account is invalid",... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/order/orderable.rb | app/models/concerns/order/orderable.rb | # frozen_string_literal: true
module Order::Orderable
def require_shipping?
is_a?(Order) ? super : link.require_shipping?
end
def receipt_for_gift_receiver?
is_a?(Order) ? super : is_gift_receiver_purchase?
end
def receipt_for_gift_sender?
is_a?(Order) ? super : is_gift_sender_purchase?
end
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/balance/searchable.rb | app/models/concerns/balance/searchable.rb | # frozen_string_literal: true
module Balance::Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include SearchIndexModelCommon
include ElasticsearchModelAsyncCallbacks
index_name "balances"
settings number_of_shards: 1, number_of_replicas: 0
mapping dynam... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/balance/refund_eligibility_underwriter.rb | app/models/concerns/balance/refund_eligibility_underwriter.rb | # frozen_string_literal: true
module Balance::RefundEligibilityUnderwriter
extend ActiveSupport::Concern
included do
after_commit :update_seller_refund_eligibility
end
private
def update_seller_refund_eligibility
return if user_id.blank?
return unless anticipate_refund_eligibility_changes... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/dispute_win_credits.rb | app/models/concerns/purchase/dispute_win_credits.rb | # frozen_string_literal: true
module Purchase::DisputeWinCredits
extend ActiveSupport::Concern
def create_credit_for_dispute_won_for_affiliate!(flow_of_funds, amount_cents: 0)
return if affiliate_credit_cents == 0 || amount_cents == 0
affiliate_issued_amount = BalanceTransaction::Amount.create_issued_amo... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/audience_member.rb | app/models/concerns/purchase/audience_member.rb | # frozen_string_literal: true
module Purchase::AudienceMember
extend ActiveSupport::Concern
included do
after_save :update_audience_member_details
after_destroy :remove_from_audience_member_details
end
def should_be_audience_member?
result = can_contact?
result &= purchase_state.in?(%w[succes... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/searchable.rb | app/models/concerns/purchase/searchable.rb | # frozen_string_literal: true
module Purchase::Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include ElasticsearchModelAsyncCallbacks
include SearchIndexModelCommon
include RelatedPurchaseCallbacks
index_name "purchases"
settings number_of_shards: 1, n... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/reportable.rb | app/models/concerns/purchase/reportable.rb | # frozen_string_literal: true
module Purchase::Reportable
extend ActiveSupport::Concern
def price_cents_net_of_refunds
net_of_refunds_cents(:price_cents, :amount_cents)
end
def fee_cents_net_of_refunds
net_of_refunds_cents(:fee_cents, :fee_cents)
end
def tax_cents_net_of_refunds
net_of_refun... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/charge_events_handler.rb | app/models/concerns/purchase/charge_events_handler.rb | # frozen_string_literal: true
module Purchase::ChargeEventsHandler
extend ActiveSupport::Concern
class_methods do
def handle_charge_event(event)
logger.info("Charge event: #{event.to_h.to_json}")
chargeable = Charge::Chargeable.find_by_stripe_event(event)
if chargeable.nil?
Bugsnag... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/paypal.rb | app/models/concerns/purchase/paypal.rb | # frozen_string_literal: true
module Purchase::Paypal
extend ActiveSupport::Concern
included do
scope :paypal, -> { where(charge_processor_id: PaypalChargeProcessor.charge_processor_id) }
scope :paypal_orders, -> { where.not(paypal_order_id: nil) }
scope :unsuccessful_paypal_orders, lambda { |created_... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/custom_fields.rb | app/models/concerns/purchase/custom_fields.rb | # frozen_string_literal: true
module Purchase::CustomFields
extend ActiveSupport::Concern
included do
has_many :purchase_custom_fields, dependent: :destroy
end
def custom_fields
purchase_custom_fields.map do |field|
{ name: field.name, value: field.value, type: field.type }
end
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/receipt.rb | app/models/concerns/purchase/receipt.rb | # frozen_string_literal: true
module Purchase::Receipt
extend ActiveSupport::Concern
included do
has_many :email_infos
has_many :installments, through: :email_infos
has_one :receipt_email_info_from_purchase, -> { order(id: :desc) }, class_name: "CustomerEmailInfo"
end
def receipt_email_info
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/blockable.rb | app/models/concerns/purchase/blockable.rb | # frozen_string_literal: true
module Purchase::Blockable
extend ActiveSupport::Concern
included do
include AttributeBlockable
attr_blockable :browser_guid
attr_blockable :ip_address
attr_blockable :email
attr_blockable :paypal_email, object_type: :email
attr_blockable :gifter_email, objec... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/recommended.rb | app/models/concerns/purchase/recommended.rb | # frozen_string_literal: true
module Purchase::Recommended
extend ActiveSupport::Concern
def handle_recommended_purchase
return unless successful? || preorder_authorization_successful? || is_free_trial_purchase?
return if RecommendedPurchaseInfo.where(purchase_id: id).present?
if RecommendationType.i... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/purchase/creator_analytics_callbacks.rb | app/models/concerns/purchase/creator_analytics_callbacks.rb | # frozen_string_literal: true
module Purchase::CreatorAnalyticsCallbacks
extend ActiveSupport::Concern
included do
after_commit :update_creator_analytics_cache, on: :update
def update_creator_analytics_cache(force: false)
return if !force && !%w[chargeback_date flags purchase_state stripe_refunded]... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/concerns/workflow/abandoned_cart_products.rb | app/models/concerns/workflow/abandoned_cart_products.rb | # frozen_string_literal: true
module Workflow::AbandonedCartProducts
extend ActiveSupport::Concern
included do
include Rails.application.routes.url_helpers
end
def abandoned_cart_products(only_product_and_variant_ids: false)
return [] unless abandoned_cart_type?
include_all_products = bought_pr... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/admin/sales_report.rb | app/models/admin/sales_report.rb | # frozen_string_literal: true
class Admin::SalesReport
include ActiveModel::Model
YYYY_MM_DD_FORMAT = /\A\d{4}-\d{2}-\d{2}\z/
INVALID_DATE_FORMAT_MESSAGE = "Invalid date format. Please use YYYY-MM-DD format"
ACCESSORS = %i[country_code start_date end_date sales_type].freeze
attr_accessor(*ACCESSORS)
ACCE... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/help_center/category.rb | app/models/help_center/category.rb | # frozen_string_literal: true
class HelpCenter::Category < ActiveYaml::Base
include ActiveHash::Associations
include ActiveHash::Enum
set_root_path "app/models"
has_many :articles, class_name: "HelpCenter::Article"
enum_accessor :title
def to_param
slug
end
def categories_for_same_audience
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/help_center/article.rb | app/models/help_center/article.rb | # frozen_string_literal: true
# Explicitly require the dependency HelpCenter::Category to avoid circular
# dependency that results in a deadlock during loading.
require "help_center/category"
class HelpCenter::Article < ActiveYaml::Base
include ActiveHash::Associations
set_root_path "app/models"
belongs_to :c... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/mailer_info/encryption.rb | app/models/mailer_info/encryption.rb | # frozen_string_literal: true
module MailerInfo::Encryption
extend self
include Kernel
def encrypt(value)
return value if value.nil?
cipher = OpenSSL::Cipher.new("aes-256-cbc")
cipher.encrypt
key_version = current_key_version
cipher.key = derive_key(key_version)
iv = cipher.random_iv
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/mailer_info/header_builder.rb | app/models/mailer_info/header_builder.rb | # frozen_string_literal: true
require "openssl"
class MailerInfo::HeaderBuilder
attr_reader :mailer_class, :email_provider
attr_reader :mailer_args
attr_reader :mailer_method
def self.perform(mailer_class:, mailer_method:, mailer_args:, email_provider:)
new(mailer_class:, mailer_method:, mailer_args:, ema... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/mailer_info/router.rb | app/models/mailer_info/router.rb | # frozen_string_literal: true
module MailerInfo::Router
extend self
include Kernel
def determine_email_provider(domain)
raise ArgumentError, "Invalid domain: #{domain}" unless MailerInfo::DeliveryMethod::DOMAINS.include?(domain)
return MailerInfo::EMAIL_PROVIDER_SENDGRID if Feature.inactive?(:resend)
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/models/mailer_info/delivery_method.rb | app/models/mailer_info/delivery_method.rb | # frozen_string_literal: true
module MailerInfo::DeliveryMethod
extend self
include Kernel
DOMAIN_GUMROAD = :gumroad
DOMAIN_FOLLOWERS = :followers
DOMAIN_CREATORS = :creators
DOMAIN_CUSTOMERS = :customers
DOMAINS = [DOMAIN_GUMROAD, DOMAIN_FOLLOWERS, DOMAIN_CREATORS, DOMAIN_CUSTOMERS]
def options(do... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/sendable_to_kindle.rb | app/modules/sendable_to_kindle.rb | # frozen_string_literal: true
module SendableToKindle
extend ActiveSupport::Concern
included do
def send_to_kindle(kindle_email)
raise ArgumentError, "Please enter a valid Kindle email address" unless kindle_email.match(KINDLE_EMAIL_REGEX)
CustomerMailer.send_to_kindle(kindle_email, id).deliver_l... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/recommendation_type.rb | app/modules/recommendation_type.rb | # frozen_string_literal: true
module RecommendationType
GUMROAD_DISCOVER_RECOMMENDATION = "discover"
GUMROAD_SEARCH_RECOMMENDATION = "search"
GUMROAD_RECEIPT_RECOMMENDATION = "receipt"
GUMROAD_LIBRARY_RECOMMENDATION = "library"
GUMROAD_MORE_LIKE_THIS_RECOMMENDATION = "more_like_this"
GUMROAD_PRODUCTS_FOR_Y... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/platform.rb | app/modules/platform.rb | # frozen_string_literal: true
module Platform
WEB = "web"
IPHONE = "iphone"
ANDROID = "android"
OTHER = "other"
def self.all
[
WEB,
IPHONE,
ANDROID,
OTHER
]
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/with_product_files_many_to_many.rb | app/modules/with_product_files_many_to_many.rb | # frozen_string_literal: true
# A module to include the WithProductFiles module
# and allow for has_and_belongs_to_many relationships
# for product files
module WithProductFilesManyToMany
extend ActiveSupport::Concern
included do
include WithProductFiles
has_and_belongs_to_many :product_files
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/timestamp_scopes.rb | app/modules/timestamp_scopes.rb | # frozen_string_literal: true
module TimestampScopes
extend ActiveSupport::Concern
included do
scope :created_between, ->(range) { where(created_at: range) if range }
scope :column_between_with_offset, lambda { |column_name, range, offset|
where("date(convert_tz(#{table_name}.#{column_name}, '+00:00... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/deletable.rb | app/modules/deletable.rb | # frozen_string_literal: true
# Module for anything that uses soft deletion functionality.
module Deletable
extend ActiveSupport::Concern
included do
scope :alive, -> { where(deleted_at: nil) }
scope :deleted, -> { where.not(deleted_at: nil) }
end
def mark_deleted!
self.deleted_at = Time.curren... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/subdomain.rb | app/modules/subdomain.rb | # frozen_string_literal: true
module Subdomain
USERNAME_REGEXP = /[a-z0-9-]+/
class << self
def find_seller_by_request(request)
find_seller_by_hostname(request.host)
end
def find_seller_by_hostname(hostname)
if subdomain_request?(hostname)
subdomain = ActionDispatch::Http::URL.ext... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/multipart_transfer.rb | app/modules/multipart_transfer.rb | # frozen_string_literal: true
module MultipartTransfer
# Public: Transfer an item from some arbitrary url source to our s3 bucket using multipart transfer
#
# source_file_url - The url of the file you wish to copy
# destination_filename - Optional, the destination filename of the file you want to copy over, u... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/utilities.rb | app/modules/utilities.rb | # frozen_string_literal: true
module Utilities
module_function
def sign_with_aws_secret_key(to_sign)
Base64.encode64(
OpenSSL::HMAC.digest(
OpenSSL::Digest.new("sha1"), AWS_SECRET_KEY, to_sign
)
).delete("\n")
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/discount_code.rb | app/modules/discount_code.rb | # frozen_string_literal: true
# DiscountCode is where all discounts for ServiceCharges are kept. They are broken into 2 types:
# cents & percentage just like OfferCodes. There is either an amount directly correlated to the type
# (e.g. type: :percentage, amount: 50 --> 50% off) or a function name which is used to calc... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/with_product_files.rb | app/modules/with_product_files.rb | # frozen_string_literal: true
module WithProductFiles
def self.included(base)
base.class_eval do
has_many :product_files
has_many :ordered_alive_product_files, -> { alive.in_order }, class_name: "ProductFile"
has_many :product_files_archives
has_many :product_folders, -> { alive }, foreig... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/money_formatter.rb | app/modules/money_formatter.rb | # frozen_string_literal: true
module MoneyFormatter
module_function
def format(amount, currency_type, opts = {})
amount ||= 0
# use the default symbol unless explicitly stated not to use one
opts[:symbol] = CURRENCY_CHOICES[currency_type][:symbol] unless opts[:symbol] == false
Money.new(amount, cu... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/cdn_deletable.rb | app/modules/cdn_deletable.rb | # frozen_string_literal: true
module CdnDeletable
extend ActiveSupport::Concern
included do
scope :alive_in_cdn, -> { where(deleted_from_cdn_at: nil) }
scope :cdn_deletable, -> { s3.deleted.alive_in_cdn }
end
def deleted_from_cdn?
deleted_from_cdn_at.present?
end
def mark_deleted_from_cdn
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/integrations.rb | app/modules/integrations.rb | # frozen_string_literal: true
module Integrations
def find_integration_by_name(name)
active_integrations.by_name(name).first
end
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/paypal_api_response.rb | app/modules/paypal_api_response.rb | # frozen_string_literal: true
module PaypalApiResponse
def open_struct_to_hash(object, hash = {})
case object
when OpenStruct
object.each_pair do |key, value|
hash[key] = case value
when OpenStruct then open_struct_to_hash(value)
when Array then value.map... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/with_file_properties.rb | app/modules/with_file_properties.rb | # frozen_string_literal: true
module WithFileProperties
include InfosHelper
MAX_DOWNLOAD_SIZE = 1_073_741_824 # 1gb
MAX_VIDEO_DOWNLOAD_SIZE = 40.gigabytes
def file_info(require_shipping = false)
# One-off for not showing image properties for a physical product.
return {} if filegroup == "image" && re... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/mongo_collections.rb | app/modules/mongo_collections.rb | # frozen_string_literal: true
module MongoCollections
EXTRA_EVENT_DATA = "extra_event_data"
USER_SUSPENSION_TIME = "user_suspension_time"
USER_FLAG_TIME = "user_flag_time"
USER_RISK_STATE = "user_risk_state"
SCIENCE_OF_DOGS_CARDS = "science_of_dogs_cards"
LINK = "Link"
PURCHASE = "Purchase"
USER = "Use... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/twitter_cards.rb | app/modules/twitter_cards.rb | # frozen_string_literal: true
module TwitterCards
TWITTER_CARD_DOMAIN = "Gumroad"
module_function
def twitter_product_card(link, product_description: nil)
card = "summary"
preview = {}
description = if product_description.present?
product_description
elsif link.description.present?
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/mongoable.rb | app/modules/mongoable.rb | # frozen_string_literal: true
module Mongoable
def time_fields
raise NotImplementedError
end
def to_mongo
attributes_to_save = attributes
attributes_to_save["updated_at"] = Time.current
time_fields.each do |field|
attributes_to_save[field] = send(field.to_sym).utc.to_time if send(field.to... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/vertical.rb | app/modules/vertical.rb | # frozen_string_literal: true
module Vertical
FILM = "film"
MUSIC = "music"
PUBLISHING = "publishing"
EDUCATION = "education"
SOFTWARE = "software"
PHYSICAL = "physical"
OTHER = "other"
NOTHING = "nothing"
end
| ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/obfuscate_ids.rb | app/modules/obfuscate_ids.rb | # frozen_string_literal: true
require "openssl"
require "base64"
module ObfuscateIds
CIPHER_KEY = GlobalConfig.get("OBFUSCATE_IDS_CIPHER_KEY")
NUMERIC_CIPHER_KEY = GlobalConfig.get("OBFUSCATE_IDS_NUMERIC_CIPHER_KEY").to_i
MAX_BYTES_FOR_NUMERIC_ENCRYPTION = 30
def self.encrypt(id, padding: true)
c = ciphe... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/purchase_error_code.rb | app/modules/purchase_error_code.rb | # frozen_string_literal: true
module PurchaseErrorCode
INVALID_NUMBER = "invalid_number"
HIGH_RISK_COUNTRY = "high_risk_country"
PRICE_TOO_HIGH = "price_too_high"
BLOCKED_BROWSER_GUID = "blocked_browser_guid"
BLOCKED_EMAIL_DOMAIN = "blocked_email_domain"
BLOCKED_IP_ADDRESS = "blocked_ip_address"
BLOCKED... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/elasticsearch_model_async_callbacks.rb | app/modules/elasticsearch_model_async_callbacks.rb | # frozen_string_literal: true
module ElasticsearchModelAsyncCallbacks
extend ActiveSupport::Concern
include TransactionalAttributeChangeTracker
included do
after_commit lambda { send_to_elasticsearch("index") }, on: :create
after_commit lambda { send_to_elasticsearch("update") }, on: :update
after_c... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/lograge_helper.rb | app/modules/lograge_helper.rb | # frozen_string_literal: true
module LogrageHelper
def append_info_to_payload(payload)
super
payload[:remote_ip] = request.remote_ip
payload[:uuid] = request.uuid
payload[:headers] = {
"CF-RAY" => request.headers["HTTP_CF_RAY"],
"X-Amzn-Trace-Id" => request.headers["HTTP_X_AMZN_TR... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/with_cdn_url.rb | app/modules/with_cdn_url.rb | # frozen_string_literal: true
module WithCdnUrl
include CdnUrlHelper
extend ActiveSupport::Concern
class_methods do
def has_cdn_url(*attributes)
attributes.each do |attribute|
define_method attribute do
replace_s3_urls_with_cdn_urls(self.attributes[attribute.to_s])
end
... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
antiwork/gumroad | https://github.com/antiwork/gumroad/blob/638f6c3a40b23b907c09f6881d4df18339da069c/app/modules/external_id.rb | app/modules/external_id.rb | # frozen_string_literal: true
module ExternalId
extend ActiveSupport::Concern
def external_id
ObfuscateIds.encrypt(id)
end
def external_id_numeric
ObfuscateIds.encrypt_numeric(id)
end
class_methods do
def to_external_id(id)
ObfuscateIds.encrypt(id)
end
def from_external_id(ext... | ruby | MIT | 638f6c3a40b23b907c09f6881d4df18339da069c | 2026-01-04T15:39:11.815677Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.