Skip to content

Commit

Permalink
Little bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
tute committed Feb 9, 2012
1 parent faec4bd commit f583352
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Define rules on +app/models/merit_badge_rules.rb+:
* :+badge+ for badge name
* :+level+ for badge level
* :+to+: method name over target_object which obtains user to badge.
* :+temporary+ (boolean): if the condition doesn't hold and the receiver had
the badge, it gets removed. +false+ by default (badges are kept forever).
* :+model_name+ (string): when controller's name differs from the model being
worked (like RegistrationsController for User model).
* :+temporary+ (boolean): if the condition doesn't hold and the receiver had
the badge, it gets removed. +false+ by default (badges are kept forever).
* &+block+
* empty (always grants)
* a block which evaluates to boolean (recieves target object as parameter)
Expand Down Expand Up @@ -117,11 +117,11 @@ Added +had_errors+ boolean attribute to +merit_actions+ table.
= Test application

To run the test application inside this gem follow:
1. cd test/dummy
2. rails g merit:install
3. rails g merit user
4. rake db:migrate ; rake db:seed
5. rails s
cd test/dummy
rails g merit:install
rails g merit user
rake db:migrate ; rake db:seed
rails s


= To-do list
Expand Down
7 changes: 4 additions & 3 deletions lib/merit/rules_badge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ module BadgeRules
def grant_on(action, *args, &block)
options = args.extract_options!

actions = action.kind_of?(String) ? [action] : action

rule = Rule.new
rule.badge_name = options[:badge]
rule.level = options[:level]
rule.to = options[:to] || :action_user
rule.temporary = options[:temporary] || false
rule.model_name = options[:model_name] || action.split('#')[0]
rule.model_name = options[:model_name] || actions[0].split('#')[0]
rule.block = block

actions = action.kind_of?(String) ? [action] : action
actions.each do |action|
defined_rules[action] ||= []
defined_rules[action] << rule
Expand All @@ -62,4 +63,4 @@ def defined_rules
@defined_rules ||= {}
end
end
end
end
2 changes: 1 addition & 1 deletion merit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Gem::Specification.new do |s|
s.summary = "General reputation Rails engine."
s.description = "General reputation Rails engine."
s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
s.version = "0.2.2"
s.version = "0.2.4"
s.authors = ["Tute Costa"]
s.email = 'tutecosta@gmail.com'
end

0 comments on commit f583352

Please sign in to comment.