plan_features 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07bd254cc2719b84d37ac6a37f197e7c90e8c7ac54c5a27d92b4599a63773f95
4
- data.tar.gz: a7efa17ace3fa438a0da2df4e7928558d9f72aad8f941c768f73a0d858a58afc
3
+ metadata.gz: 933f122a502003c040a93b139504dab852420e39aef6924eb98315c5ec050c23
4
+ data.tar.gz: 60b5d33a06068363db0be20d10f04b0aa95cdb4d6b5e767091735ff4cf7b36f9
5
5
  SHA512:
6
- metadata.gz: a1fea6c3e978ace802ff4658ec1f692ae9035bb68f84a6f19ade4c3b51c79d46ed399aeecdd019e1d850c8232fcd34b06717e14ca23aa419b92f97ab2db6ea65
7
- data.tar.gz: d970c2cb9c7b452f8f48780cc7eb763075a602bf01cca2fd91cc0191f00327f881d631eb880f590a49eff65a9ea8eb873556764df5100524c6b60cb7da26ae89
6
+ metadata.gz: bdd83eee10774dcdf1ca0f9999772a112f58549dd429c5ea9deb411acc2fe75bba7826ad2c4082b2b0b476c99e9a0debe1d73ec02550733419547097a3c5c780
7
+ data.tar.gz: 777675e2816585d93a4f219be4b4b8e64975393ae7c4efe8aafbe962be8cc406f6b5d4876683fbe96d584f80b7b89e1af59389c49751c7015b9453b633a437dd
data/README.md CHANGED
@@ -100,6 +100,17 @@ paid_plan.limit_for(:posts)
100
100
  # => 50
101
101
  ```
102
102
 
103
+ ### Metadata
104
+
105
+ You can add metadata to a plan by using the `metadata` key. Example:
106
+
107
+ ```
108
+ paid:
109
+ name: "Paid"
110
+ metadata:
111
+ popular: true
112
+ ```
113
+
103
114
  ## Installation
104
115
 
105
116
  Add this line to your application's Gemfile:
@@ -2,7 +2,7 @@ require_relative "feature"
2
2
 
3
3
  module PlanFeatures
4
4
  class Pricing
5
- attr_accessor :name, :plan_identifier, :interval, :stripe_id, :features, :prices, :previous, :popular
5
+ attr_accessor :name, :plan_identifier, :interval, :stripe_id, :features, :prices, :previous, :metadata
6
6
 
7
7
  include ActiveModel::Model
8
8
 
@@ -29,11 +29,11 @@ module PlanFeatures
29
29
  @all_plans ||= YAML.load_file(::PlanFeatures.configuration.plans_file_path).map do |plan, attributes|
30
30
  Pricing.new(
31
31
  plan_identifier: plan,
32
- popular: attributes["popular"],
33
32
  name: attributes["name"],
34
33
  features: attributes["features"],
35
34
  prices: attributes["prices"],
36
- previous: attributes["previous"]
35
+ previous: attributes["previous"],
36
+ metadata: attributes["metadata"]&.with_indifferent_access,
37
37
  )
38
38
  end
39
39
  end
@@ -63,7 +63,7 @@ module PlanFeatures
63
63
  end
64
64
 
65
65
  def limit_for(feature)
66
- features.dig(feature.to_s, "limit")
66
+ features.dig(feature.to_s, "limit") || 0
67
67
  end
68
68
 
69
69
  def free?
@@ -1,3 +1,3 @@
1
1
  module PlanFeatures
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan_features
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesper Christiansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2023-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails