Permalink
Browse files

Merge branch 'master' of https://github.com/t6d/acts_as_api into t6d-…

…master

Conflicts:
	lib/acts_as_api/api_template.rb
  • Loading branch information...
2 parents 6edc48e + 17a0d84 commit e9900c07f3ca34692b7f5f2c9c2db7c9c4ca5e60 @fabrik42 committed Apr 10, 2012
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/acts_as_api/api_template.rb
@@ -67,10 +67,16 @@ def api_template_for(fieldset, field)
# the response based on the conditional options passed.
def allowed_to_render?(fieldset, field, model, options)
return true unless fieldset.is_a? ActsAsApi::ApiTemplate
- allowed = true
- allowed = condition_fulfilled?(model, fieldset.option_for(field, :if), options) if fieldset.option_for(field, :if)
- allowed = !(condition_fulfilled?(model, fieldset.option_for(field, :unless), options)) if fieldset.option_for(field, :unless)
- return allowed
+
+ fieldset_options = fieldset.options_for(field)
+
+ if fieldset_options[:unless]
+ !(condition_fulfilled?(model, fieldset_options[:unless], options))
+ elsif fieldset_options[:if]
+ condition_fulfilled?(model, fieldset_options[:if], options)
+ else
+ true
+ end
end
# Checks if a condition is fulfilled

0 comments on commit e9900c0

Please sign in to comment.