removing extra white space at end of lines
This commit is contained in:
@@ -188,9 +188,9 @@ module CanCan
|
||||
def query(action, subject)
|
||||
Query.new(subject, relevant_can_definitions_for_query(action, subject))
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
# Accepts a hash of aliased actions and returns an array of actions which match.
|
||||
# This should be called before "matches?" and other checking methods since they
|
||||
# rely on the actions to be expanded.
|
||||
|
||||
@@ -10,7 +10,7 @@ module CanCan
|
||||
@parent = parent
|
||||
@options = options
|
||||
end
|
||||
|
||||
|
||||
# Returns the class used for this resource. This can be overriden by the :resource option.
|
||||
# Sometimes one will use a symbol as the resource if a class does not exist for it. In that
|
||||
# case "find" and "build" should not be called on it.
|
||||
@@ -24,27 +24,27 @@ module CanCan
|
||||
resource_class # could be a symbol
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def find(id)
|
||||
self.model_instance ||= base.find(id)
|
||||
end
|
||||
|
||||
|
||||
# Build a new instance of this resource. If it is a class we just call "new" otherwise
|
||||
# it's an associaiton and "build" is used.
|
||||
def build(attributes)
|
||||
self.model_instance ||= (base.kind_of?(Class) ? base.new(attributes) : base.build(attributes))
|
||||
end
|
||||
|
||||
|
||||
def model_instance
|
||||
@controller.instance_variable_get("@#{@name}")
|
||||
end
|
||||
|
||||
|
||||
def model_instance=(instance)
|
||||
@controller.instance_variable_set("@#{@name}", instance)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
# The object that methods (such as "find", "new" or "build") are called on.
|
||||
# If there is a parent it will be the association, otherwise it will be the model's class.
|
||||
def base
|
||||
|
||||
@@ -7,16 +7,16 @@ module CanCan
|
||||
@sanitizer = sanitizer
|
||||
@can_definitions = can_definitions
|
||||
end
|
||||
|
||||
|
||||
# Returns a string of SQL conditions which match the ability query.
|
||||
#
|
||||
#
|
||||
# can :manage, User, :id => 1
|
||||
# can :manage, User, :manager_id => 1
|
||||
# cannot :manage, User, :self_managed => true
|
||||
# query(:manage, User).conditions # => "not (self_managed = 't') AND ((manager_id = 1) OR (id = 1))"
|
||||
#
|
||||
# Normally you will not call this method directly, but instead go through ActiveRecordAdditions#accessible_by.
|
||||
#
|
||||
#
|
||||
# If there is just one :can ability, it conditions returned untouched.
|
||||
def conditions
|
||||
if @can_definitions.size == 1 && @can_definitions.first.base_behavior
|
||||
@@ -28,7 +28,7 @@ module CanCan
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Returns the associations used in conditions for the :joins option of a search
|
||||
# See ActiveRecordAdditions#accessible_by for use in Active Record.
|
||||
def joins
|
||||
@@ -38,9 +38,9 @@ module CanCan
|
||||
end
|
||||
clean_joins(joins_hash) unless joins_hash.empty?
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
|
||||
def merge_conditions(sql, conditions_hash, behavior)
|
||||
if conditions_hash.blank?
|
||||
behavior ? true_sql : false_sql
|
||||
@@ -68,7 +68,7 @@ module CanCan
|
||||
def sanitize_sql(conditions)
|
||||
@sanitizer.sanitize_sql(conditions)
|
||||
end
|
||||
|
||||
|
||||
def merge_joins(base, add)
|
||||
add.each do |name, nested|
|
||||
if base[name].is_a?(Hash) && !nested.empty?
|
||||
@@ -78,7 +78,7 @@ module CanCan
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def clean_joins(joins_hash)
|
||||
joins = []
|
||||
joins_hash.each do |name, nested|
|
||||
|
||||
Reference in New Issue
Block a user