merit 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +7 -7
  2. data/lib/merit/rules_badge.rb +4 -3
  3. metadata +1 -1
data/README.rdoc CHANGED
@@ -26,10 +26,10 @@ Define rules on +app/models/merit_badge_rules.rb+:
26
26
  * :+badge+ for badge name
27
27
  * :+level+ for badge level
28
28
  * :+to+: method name over target_object which obtains user to badge.
29
- * :+temporary+ (boolean): if the condition doesn't hold and the receiver had
30
- the badge, it gets removed. +false+ by default (badges are kept forever).
31
29
  * :+model_name+ (string): when controller's name differs from the model being
32
30
  worked (like RegistrationsController for User model).
31
+ * :+temporary+ (boolean): if the condition doesn't hold and the receiver had
32
+ the badge, it gets removed. +false+ by default (badges are kept forever).
33
33
  * &+block+
34
34
  * empty (always grants)
35
35
  * a block which evaluates to boolean (recieves target object as parameter)
@@ -117,11 +117,11 @@ Added +had_errors+ boolean attribute to +merit_actions+ table.
117
117
  = Test application
118
118
 
119
119
  To run the test application inside this gem follow:
120
- 1. cd test/dummy
121
- 2. rails g merit:install
122
- 3. rails g merit user
123
- 4. rake db:migrate ; rake db:seed
124
- 5. rails s
120
+ cd test/dummy
121
+ rails g merit:install
122
+ rails g merit user
123
+ rake db:migrate ; rake db:seed
124
+ rails s
125
125
 
126
126
 
127
127
  = To-do list
@@ -35,15 +35,16 @@ module Merit
35
35
  def grant_on(action, *args, &block)
36
36
  options = args.extract_options!
37
37
 
38
+ actions = action.kind_of?(String) ? [action] : action
39
+
38
40
  rule = Rule.new
39
41
  rule.badge_name = options[:badge]
40
42
  rule.level = options[:level]
41
43
  rule.to = options[:to] || :action_user
42
44
  rule.temporary = options[:temporary] || false
43
- rule.model_name = options[:model_name] || action.split('#')[0]
45
+ rule.model_name = options[:model_name] || actions[0].split('#')[0]
44
46
  rule.block = block
45
47
 
46
- actions = action.kind_of?(String) ? [action] : action
47
48
  actions.each do |action|
48
49
  defined_rules[action] ||= []
49
50
  defined_rules[action] << rule
@@ -62,4 +63,4 @@ module Merit
62
63
  @defined_rules ||= {}
63
64
  end
64
65
  end
65
- end
66
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: