scoreable 0.0.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.2.0
@@ -28,29 +28,33 @@ module Scoreable
28
28
  if score_config.is_a? Hash
29
29
  score = score_config[Scoreable.score_term.to_sym]
30
30
  callback_method = score_config[:callback]
31
- receivers = score_config[:for]
31
+ receivers = score_config[:for] || score_receiver
32
+ force_save = score_config[:save]
32
33
  else
33
34
  callback_method = nil
34
- receivers = [score_receiver]
35
+ receivers = score_receiver
35
36
  score = score_config
37
+ force_save = false
36
38
  end
37
- actions = action.is_a?(Array) ? action : [action.to_s]
39
+
40
+ receivers = [receivers] unless receivers.is_a? Array
41
+ actions = [action] unless action.is_a? Array
38
42
 
39
43
  actions.each do |action|
40
- action= action.to_s
41
- method_without_score_feature = action+"_without_#{Scoreable.score_term}"
42
- method_with_score_feature = action+"_with_#{Scoreable.score_term}"
44
+ action = action.to_s
45
+ method_without_score_feature = action + "_without_#{Scoreable.score_term}"
46
+ method_with_score_feature = action + "_with_#{Scoreable.score_term}"
43
47
 
44
48
  Scoreable::Generator::GeneratedMethods.class_eval do
45
49
  define_method method_with_score_feature.to_sym do
46
50
  send method_without_score_feature
47
51
  receivers.each do |receiver|
52
+ send(receiver).save! if force_save
48
53
  score_obj= log_score score,action, receiver
49
54
 
50
55
  send callback_method,score_obj if callback_method
56
+ score_obj
51
57
  end
52
-
53
-
54
58
  end
55
59
  end
56
60
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{scoreable}
8
- s.version = "0.0.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Naveed Ahmad}]
12
- s.date = %q{2012-09-11}
12
+ s.date = %q{2012-09-29}
13
13
  s.description = %q{longer description of your gem}
14
14
  s.email = %q{naveedahmada036@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scoreable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
12
+ date: 2012-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70464070 !ruby/object:Gem::Requirement
16
+ requirement: &84884400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.8.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70464070
24
+ version_requirements: *84884400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &70463720 !ruby/object:Gem::Requirement
27
+ requirement: &84883950 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.12'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70463720
35
+ version_requirements: *84883950
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &70463370 !ruby/object:Gem::Requirement
38
+ requirement: &84883560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.2.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70463370
46
+ version_requirements: *84883560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70463030 !ruby/object:Gem::Requirement
49
+ requirement: &84883310 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.8.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70463030
57
+ version_requirements: *84883310
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &70462760 !ruby/object:Gem::Requirement
60
+ requirement: &84883010 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70462760
68
+ version_requirements: *84883010
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
- requirement: &70462350 !ruby/object:Gem::Requirement
71
+ requirement: &84882640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70462350
79
+ version_requirements: *84882640
80
80
  description: longer description of your gem
81
81
  email: naveedahmada036@gmail.com
82
82
  executables: []
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  segments:
125
125
  - 0
126
- hash: 1026594223
126
+ hash: -990501421
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements: