Sha256: 4dab4af98d408aa1178ac69e0915eb93f5a81c25710232f155d301e7b5badd0a
Contents?: true
Size: 1.28 KB
Versions: 9
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Maquina ## # A class representing the Plan model in the Maquina module. # # == Attributes # # - +price+:: The price of the Plan, represented as a monetary value with currency. # - +name+:: The name of the Plan. # # == Validations # # - +price+:: Must be greater than or equal to 0 if the Plan is marked as free. # - +price+:: Must be greater than 0 if the Plan is not marked as free. # - +name+:: Must be present and unique. # # == Scopes # # - +search_full+:: Provides a search scope for Plan model, allowing searching by name with options for prefix matching and matching any word. # # == Usage # # The Plan model represents a pricing plan in the Maquina module. To use the Plan model, create instances with valid # attributes and use the provided methods and scopes for querying and manipulating plan data. class Plan < ApplicationRecord has_many :organizations, class_name: "Maquina::Organization", foreign_key: :maquina_plan_id, dependent: :nullify monetize :price_cents validates :price, numericality: {greater_than_or_equal_to: 0}, if: ->(plan) { plan.free? } validates :price, numericality: {greater_than: 0}, if: ->(plan) { !plan.free? } validates :name, presence: true, uniqueness: true end end
Version data entries
9 entries across 9 versions & 1 rubygems