- A
- C
- D
- F
- L
- M
- R
- U
Class Public methods
agency_mode_features_config() Link
Source: show
# File app/models/member_space_plan.rb, line 73 def agency_mode_features_config { can_create_organization: [:boolean, default: false] } # These doen't need to be checked during +recommended+, # which is what the +limits_config+ and +features_config+ are for. end
current_plans_sorted_by_max_sites() Link
Source: show
# File app/models/member_space_plan.rb, line 186 def current_plans_sorted_by_max_sites current.limits_order(:max_sites) end
default_can_remove_branding() Link
Source: show
# File app/models/member_space_plan.rb, line 196 def default_can_remove_branding new.can_remove_branding? end
downgrade_allowed_features_config() Link
Source: show
# File app/models/member_space_plan.rb, line 52 def downgrade_allowed_features_config { can_remove_branding: [:boolean, default: false] } end
downgrade_allowed_limits_config() Link
Source: show
# File app/models/member_space_plan.rb, line 48 def downgrade_allowed_limits_config {} end
downgrade_restricted_features() Link
Source: show
# File app/models/member_space_plan.rb, line 97 def downgrade_restricted_features downgrade_restricted_features_config.keys end
downgrade_restricted_features_config() Link
Source: show
# File app/models/member_space_plan.rb, line 64 def downgrade_restricted_features_config { can_create_free_plans: [:boolean, default: false], can_invite_site_admins: [:boolean, default: false], can_setup_integrations: [:boolean, default: false], can_send_broadcasts: [:boolean, default: false] } end
downgrade_restricted_limits() Link
Source: show
# File app/models/member_space_plan.rb, line 101 def downgrade_restricted_limits downgrade_restricted_limits_config.keys end
downgrade_restricted_limits_config() Link
Source: show
# File app/models/member_space_plan.rb, line 58 def downgrade_restricted_limits_config { max_sites: [:integer, default: 0] # 0 == unlimited == max_sites? => false } end
features() Link
Source: show
# File app/models/member_space_plan.rb, line 89 def features features_config.keys end
features_config() Link
Source: show
# File app/models/member_space_plan.rb, line 85 def features_config downgrade_restricted_features_config.merge(downgrade_allowed_features_config) end
features_in_use(site_owner: nil, site: nil, include_sites: []) Link
Used by the recommended query
Returns a Hash map of only true values for features in use by any plan-applicable site owned by the given site_owner
Does not return false values for features not in use, because that would not be compatible with querying for the recommended plan; such plans potentially have those features set to true
Example:
# If any owned site has customized their email and/or removed branding:
{ can_send_broadcasts: true, can_remove_branding: true }
Source: show
# File app/models/member_space_plan.rb, line 135 def features_in_use(site_owner: nil, site: nil, include_sites: []) sites = (Array(include_sites) << site).compact if site_owner.present? sites += site_owner.becomes(SiteOwner).sites_under_plan end features_config.keys.map do |feature| [ feature, sites.any? { |site| using_feature?(site:, feature:) } ] end.to_h.reject { |k, v| !v } end
limits() Link
Source: show
# File app/models/member_space_plan.rb, line 93 def limits limits_config.keys end
limits_config() Link
Source: show
# File app/models/member_space_plan.rb, line 81 def limits_config downgrade_restricted_limits_config.merge(downgrade_allowed_limits_config) end
recommended_upgrade(site_owner:, feature: nil, include_sites: []) Link
Source: show
# File app/models/member_space_plan.rb, line 110 def recommended_upgrade(site_owner:, feature: nil, include_sites: []) attrs = {site_owner: site_owner, include_sites: Array(include_sites)} attrs[:feature] = feature if feature.present? attrs[:comparison] = :greater_than if feature&.to_sym == :max_sites recommended(**attrs).first end
revert_downgraded_feature_can_remove_branding(site_owner) Link
Source: show
# File app/models/member_space_plan.rb, line 190 def revert_downgraded_feature_can_remove_branding(site_owner) site_owner.sites_under_plan.each do |site| site.settings.update!(remove_memberspace_branding: default_can_remove_branding) end end
revert_downgraded_features(site_owner:) Link
Source: show
# File app/models/member_space_plan.rb, line 155 def revert_downgraded_features(site_owner:) return unless site_owner&.of_memberspace? site_owner = site_owner.becomes(SiteOwner) downgrade_allowed_features_config .keys .reject { |f| site_owner.feature_enabled?(f) } .each { |f| send("revert_downgraded_feature_#{f}", site_owner) } end
using_feature?(site:, feature:) Link
Source: show
# File app/models/member_space_plan.rb, line 150 def using_feature?(site:, feature:) feature = String(feature).sub(/\?$/, "") send("using_feature_#{feature}?", site) end
using_feature_can_create_free_plans?(site) Link
Source: show
# File app/models/member_space_plan.rb, line 170 def using_feature_can_create_free_plans?(site) site.plans.free_plan_type.any? end
using_feature_can_invite_site_admins?(site) Link
Source: show
# File app/models/member_space_plan.rb, line 182 def using_feature_can_invite_site_admins?(site) site.administrators.any? end
using_feature_can_remove_branding?(site) Link
Source: show
# File app/models/member_space_plan.rb, line 174 def using_feature_can_remove_branding?(site) site.settings.remove_memberspace_branding? end
using_feature_can_send_broadcasts?(site) Link
Source: show
# File app/models/member_space_plan.rb, line 166 def using_feature_can_send_broadcasts?(site) site.email_from_address != DB::SiteSettings.default_from_address end
using_feature_can_setup_integrations?(site) Link
Source: show
# File app/models/member_space_plan.rb, line 178 def using_feature_can_setup_integrations?(site) site.integrations.any? end
Instance Public methods
current?() Link
Source: show
# File app/models/member_space_plan.rb, line 221 def current? is_public? && enabled? end
feature_disabled?(feature_name) Link
Source: show
# File app/models/member_space_plan.rb, line 205 def feature_disabled?(feature_name) !feature_enabled?(feature_name) end
feature_enabled?(feature_name) Link
Source: show
# File app/models/member_space_plan.rb, line 201 def feature_enabled?(feature_name) public_send(feature_name) end
limit(limit_name) Link
Source: show
# File app/models/member_space_plan.rb, line 209 def limit(limit_name) public_send(limit_name) end
limited?(limit_name) Link
Source: show
# File app/models/member_space_plan.rb, line 217 def limited?(limit_name) !unlimited?(limit_name) end