paid_up 0.13.9 → 0.13.10

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: f28fb8f152c4c2521eb613e16577bd1786020ba4096870e6ff1c2d634e5d5f89
4
- data.tar.gz: 70638bf5f140c2bd8f29ba20a7b3cbdc478fabfac70850ec4a3c546b2a461490
3
+ metadata.gz: 190f8e3cccb7803e7b0b41c0e32949fbab57943bb7b6b1c6077435a1e26047b9
4
+ data.tar.gz: 7edf4a9c282c68c57b00544a4f5159e0e1384125d2398955a70a6dc100cb6d8d
5
5
  SHA512:
6
- metadata.gz: fbd4048b015c852506a407b6878db339954bead9bb09eac2419642384e59fc828689625d020450c5b1406f2c5e3ae05c60eb9ecb30591af1a8389cec9cf7a944
7
- data.tar.gz: 5f914bebd065f4920085e61d92250d2985eac61f6ead794a6c36fe12328cad3c199c8dd1969b104255b62364c43f0e547374a99b7dda0e5a7837ab27f5e24c75
6
+ metadata.gz: d31259ba34e6d998e024dbaa4bc64503925b4b509d7e52b8c6c2a7cb0fa436aab9f49abe24aa30e905ceab8bb56bbcc77463317dba14f118e0469b50e2a3fba5
7
+ data.tar.gz: a69b0a79d9944e9a974b9bae17a026f85a2d26211ef962b323564d27a94935d83cb4a9c7c19683a4760cf082404cc28a17d862fb937f38762918a48eda81a526
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.9
1
+ 0.13.10
@@ -17,6 +17,7 @@ module PaidUp
17
17
  class Feature
18
18
  include ActiveModel::Model
19
19
  include ActiveModel::AttributeMethods
20
+ extend ActiveSupport::Concern
20
21
 
21
22
  attr_accessor :slug, :title, :setting_type, :description
22
23
 
@@ -38,8 +39,52 @@ module PaidUp
38
39
  found_in: 'slug'
39
40
  )
40
41
 
41
- def self.raw
42
- PaidUp.features
42
+ class << self
43
+ def raw
44
+ PaidUp.features
45
+ end
46
+
47
+ def find_by_slug(slug)
48
+ raw[slug.to_sym]
49
+ end
50
+
51
+ def find_by_slug!(slug)
52
+ find_by_slug(slug) || raise(:feature_not_found.l)
53
+ end
54
+
55
+ def all
56
+ raw.values
57
+ end
58
+
59
+ def find_all(**conditions)
60
+ collection = []
61
+ all.each do |feature|
62
+ qualifies = true
63
+ conditions.each do |key, value|
64
+ feature.send(key) != value && (qualifies = false)
65
+ end
66
+ qualifies && collection << feature
67
+ end
68
+ collection
69
+ end
70
+
71
+ def find(**conditions)
72
+ find_all(conditions).first
73
+ end
74
+
75
+ def method_missing(method_sym, *arguments, &block)
76
+ if method_sym.to_s =~ /^find_by_(.*)$/
77
+ find(Regexp.last_match[1].to_sym => arguments.first)
78
+ elsif method_sym.to_s =~ /^find_all_by_(.*)$/
79
+ find_all(Regexp.last_match[1].to_sym => arguments.first)
80
+ else
81
+ super
82
+ end
83
+ end
84
+
85
+ def respond_to_missing?(method_name, include_private = false)
86
+ method_name.to_s.start_with?('find_') || super
87
+ end
43
88
  end
44
89
 
45
90
  def to_s
@@ -58,46 +103,25 @@ module PaidUp
58
103
  feature_model_name.constantize
59
104
  end
60
105
 
61
- def self.find_by_slug(slug)
62
- raw[slug.to_sym]
63
- end
64
-
65
- def self.find_by_slug!(slug)
66
- find_by_slug(slug) || raise(:feature_not_found.l)
67
- end
68
-
69
- def self.all
70
- raw.values
71
- end
72
-
73
- def self.find_all(**conditions)
74
- collection = []
75
- all.each do |feature|
76
- qualifies = true
77
- conditions.each do |key, value|
78
- feature.send(key) != value && (qualifies = false)
79
- end
80
- qualifies && collection << feature
81
- end
82
- collection
106
+ def for_graphql(setting)
107
+ OpenStruct.new(
108
+ id: slug,
109
+ title: title,
110
+ slug: slug,
111
+ description: description,
112
+ setting: setting,
113
+ setting_human: setting_human(setting)
114
+ )
83
115
  end
84
116
 
85
- def self.find(**conditions)
86
- find_all(conditions).first
87
- end
88
-
89
- def self.method_missing(method_sym, *arguments, &block)
90
- if method_sym.to_s =~ /^find_by_(.*)$/
91
- find(Regexp.last_match[1].to_sym => arguments.first)
92
- elsif method_sym.to_s =~ /^find_all_by_(.*)$/
93
- find_all(Regexp.last_match[1].to_sym => arguments.first)
117
+ def setting_human(setting)
118
+ if setting == PaidUp::Unlimited.to_i
119
+ PaidUp::Unlimited.to_s
120
+ elsif setting_type == 'boolean'
121
+ setting ? :allowed.l : :not_allowed.l
94
122
  else
95
- super
123
+ setting.to_s
96
124
  end
97
125
  end
98
-
99
- def self.respond_to_missing?(method_name, include_private = false)
100
- method_name.to_s.start_with?('find_') || super
101
- end
102
126
  end
103
127
  end
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: paid_up 0.13.9 ruby lib
5
+ # stub: paid_up 0.13.10 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "paid_up".freeze
9
- s.version = "0.13.9"
9
+ s.version = "0.13.10"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Karen Lundgren".freeze]
14
- s.date = "2019-02-08"
14
+ s.date = "2019-02-11"
15
15
  s.description = "Allows a model of your choosing (such as users) to subscribe to a plan, which enables features.".freeze
16
16
  s.email = "karen.e.lundgren@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paid_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.9
4
+ version: 0.13.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karen Lundgren
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2019-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml-rails