Sha256: 6806e9dfbb7073497de5e74f5c8c3a3c71068683f8c58523fc1277b2347a4030

Contents?: true

Size: 560 Bytes

Versions: 13

Compression:

Stored size: 560 Bytes

Contents

module Saucy
  module Plan
    extend ActiveSupport::Concern

    included do
      has_many :accounts
      has_many :limits

      validates_presence_of :name
    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

13 entries across 13 versions & 1 rubygems

Version Path
saucy-0.2.10 lib/saucy/plan.rb
saucy-0.2.9 lib/saucy/plan.rb
saucy-0.2.8.1 lib/saucy/plan.rb
saucy-0.2.8 lib/saucy/plan.rb
saucy-0.2.7 lib/saucy/plan.rb
saucy-0.2.6.1 lib/saucy/plan.rb
saucy-0.2.6 lib/saucy/plan.rb
saucy-0.2.5 lib/saucy/plan.rb
saucy-0.2.4.1 lib/saucy/plan.rb
saucy-0.2.4 lib/saucy/plan.rb
saucy-0.2.3 lib/saucy/plan.rb
saucy-0.2.2 lib/saucy/plan.rb
saucy-0.2.1 lib/saucy/plan.rb