kudos 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88b2bc3c5627913f22f9bc36b10acfc596e4e576535ab447bc31ff30bad45443
4
- data.tar.gz: afc5348c4da73d71993684035eefb0d89248e6ded717faca5f6e6739c65e1c8d
3
+ metadata.gz: 794f0cfa50b1a522d89d6d5bbe5ad3c22699bbe96c2c8eaf0a3249558a946aec
4
+ data.tar.gz: 60e25e21ff551fa92d3feac2c683ed2040869d636df99bb3def1936787977ec7
5
5
  SHA512:
6
- metadata.gz: 34a55fcdfcb296a27b206e8c962053deef49b94b278e41cafc0b7e156d098224191aca358434828a931dc0aba187117f1ea75c209f6f9093886787c3fbfd09b0
7
- data.tar.gz: a8e04bb860c279878d447191bc738a3ef12104645ab6d97602c9f2e558c57a5a7c04bf301c7940c5035e448d7316c20c57886059acad8571f5b2f918b71f2f94
6
+ metadata.gz: 0aead887db0291c2729485680c81fb0d7e46bf401c439ccf6c2e64440d81d8f0a69fc261d0c92628a1f8b8686d10cc4fe2ee63a30835d9337abe76c15080187c
7
+ data.tar.gz: d45687689fd6c3f403c64a518dded792ad59901c009a31529b52a8960caa7228de8e4524500fdaffe3df4c4abe6a266747dae309f004ab7ae620a6bf5f9476ec
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kudos
4
+ class Configuration
5
+ attr_accessor :achievements_model_name
6
+
7
+ def initialize
8
+ # model name with defined award_for methods
9
+ @achievements_model_name = ::Achievement
10
+ end
11
+ end
12
+ end
data/lib/kudos/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kudos
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
data/lib/kudos.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'kudos/version'
4
4
  require 'kudos/engine'
5
+ require 'kudos/configuration'
5
6
 
6
7
  module Kudos
7
8
  def self.included(base)
@@ -11,6 +12,21 @@ module Kudos
11
12
  end
12
13
 
13
14
  module ClassMethods
15
+ # Public: Configure kudos.
16
+ #
17
+ # Kudos.configure do |config|
18
+ # config.achievements_model_name = ::Achievement
19
+ # end
20
+ #
21
+ def configure
22
+ yield configuration
23
+ end
24
+
25
+ # Public: Returns Kudos::Configuration instance.
26
+ def configuration
27
+ @configuration ||= Configuration.new
28
+ end
29
+
14
30
  def awards
15
31
  @awards ||= {}
16
32
  end
@@ -20,7 +36,7 @@ module Kudos
20
36
  end
21
37
 
22
38
  def award(award_name, *attributes)
23
- achievements = Kudos::Achievement.where(award_name: award_name).order(rank: :asc)
39
+ achievements = configuration.achievements_model_name.where(award_name: award_name).order(rank: :asc)
24
40
  awards[award_name].call(achievements, *attributes)
25
41
  end
26
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kudos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdanov Anton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-30 00:00:00.000000000 Z
11
+ date: 2022-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -162,6 +162,7 @@ files:
162
162
  - lib/generators/kudos/templates/users_achievement.erb
163
163
  - lib/generators/kudos/templates/uuidable.erb
164
164
  - lib/kudos.rb
165
+ - lib/kudos/configuration.rb
165
166
  - lib/kudos/engine.rb
166
167
  - lib/kudos/version.rb
167
168
  - lib/tasks/kudos_tasks.rake