Sha256: 5c5d54e67da4767dc43217d014906cc3609fe767d0c4c521a0c566febc0aad0b

Contents?: true

Size: 622 Bytes

Versions: 2

Compression:

Stored size: 622 Bytes

Contents

module Saucy
  module Plan
    extend ActiveSupport::Concern

    included do
      has_many :accounts
      has_many :limits

      validates_presence_of :name

      def self.ordered
        order('price desc')
      end
    end

    module InstanceMethods
      def free?
        price.zero?
      end

      def billed?
        !free?
      end

      def can_add_more?(limit, amount)
        limits.numbered.named(limit).value > amount
      end

      def allows?(limit)
        limits.boolean.named(limit).allowed?
      end

      def limit(limit_name)
        limits.named(limit_name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saucy-0.2.12 lib/saucy/plan.rb
saucy-0.2.11 lib/saucy/plan.rb