Sha256: 1f51cf3b53c58039378fe99331afe6f5df8089cade5d550165315ef5ed8ef76d

Contents?: true

Size: 734 Bytes

Versions: 21

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

# PaidUp module
module PaidUp
  # Feature Setting Type Class: Not an ActiveRecord object.
  class FeatureSettingType
    include ActiveModel::Model
    include ActiveModel::AttributeMethods

    attr_accessor :name, :user
    delegate :plan, to: :user

    def rows_unlimited?
      rows_allowed == PaidUp::Unlimited.to_i
    end

    def rows_remaining
      rows_allowed - rows_count
    end

    def rows_allowed
      plan.feature_setting name
    end

    def rows
      scope.where(user: user)
    end

    def ids
      rows.ids
    end

    def rows_count
      rows.size
    end

    def model
      name.classify.constantize
    end

    def scope
      model.paid_for_scope
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
paid_up-0.13.22 lib/paid_up/feature_setting_type.rb
paid_up-0.13.21 lib/paid_up/feature_setting_type.rb
paid_up-0.13.17 lib/paid_up/feature_setting_type.rb
paid_up-0.13.16 lib/paid_up/feature_setting_type.rb
paid_up-0.13.14 lib/paid_up/feature_setting_type.rb
paid_up-0.13.13 lib/paid_up/feature_setting_type.rb
paid_up-0.13.12 lib/paid_up/feature_setting_type.rb
paid_up-0.13.11 lib/paid_up/feature_setting_type.rb
paid_up-0.13.10 lib/paid_up/feature_setting_type.rb
paid_up-0.13.9 lib/paid_up/feature_setting_type.rb
paid_up-0.13.8 lib/paid_up/feature_setting_type.rb
paid_up-0.13.7 lib/paid_up/feature_setting_type.rb
paid_up-0.13.6 lib/paid_up/feature_setting_type.rb
paid_up-0.13.5 lib/paid_up/feature_setting_type.rb
paid_up-0.13.4 lib/paid_up/feature_setting_type.rb
paid_up-0.13.3 lib/paid_up/feature_setting_type.rb
paid_up-0.13.2 lib/paid_up/feature_setting_type.rb
paid_up-0.13.1 lib/paid_up/feature_setting_type.rb
paid_up-0.13.0 lib/paid_up/feature_setting_type.rb
paid_up-0.12.4 lib/paid_up/feature_setting_type.rb