CanDefinition#only_block?
This commit is contained in:
parent
bcab8d6369
commit
b473d8827f
|
@ -202,7 +202,7 @@ module CanCan
|
||||||
def conditions(action, subject, options = {})
|
def conditions(action, subject, options = {})
|
||||||
matched = matching_can_definition(action, subject)
|
matched = matching_can_definition(action, subject)
|
||||||
unless matched.empty?
|
unless matched.empty?
|
||||||
if matched.any?{|can_definition| can_definition.conditions_empty? && can_definition.block }
|
if matched.any?{|can_definition| can_definition.only_block? }
|
||||||
raise Error, "Cannot determine ability conditions from block for #{action.inspect} #{subject.inspect}"
|
raise Error, "Cannot determine ability conditions from block for #{action.inspect} #{subject.inspect}"
|
||||||
end
|
end
|
||||||
matched.map{|can_definition|
|
matched.map{|can_definition|
|
||||||
|
@ -258,7 +258,7 @@ module CanCan
|
||||||
def association_joins(action, subject)
|
def association_joins(action, subject)
|
||||||
can_definitions = matching_can_definition(action, subject)
|
can_definitions = matching_can_definition(action, subject)
|
||||||
unless can_definitions.empty?
|
unless can_definitions.empty?
|
||||||
if can_definitions.any?{|can_definition| can_definition.conditions_empty? && can_definition.block }
|
if can_definitions.any?{|can_definition| can_definition.only_block? }
|
||||||
raise Error, "Cannot determine association joins from block for #{action.inspect} #{subject.inspect}"
|
raise Error, "Cannot determine association joins from block for #{action.inspect} #{subject.inspect}"
|
||||||
end
|
end
|
||||||
collect_association_joins(can_definitions)
|
collect_association_joins(can_definitions)
|
||||||
|
|
|
@ -55,6 +55,10 @@ module CanCan
|
||||||
conditions_empty? && @block.nil?
|
conditions_empty? && @block.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def only_block?
|
||||||
|
conditions_empty? && !@block.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def conditions_empty?
|
def conditions_empty?
|
||||||
@conditions == {} || @conditions.nil?
|
@conditions == {} || @conditions.nil?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user