Class: CanCanCan::ActiveGraph::SingleRuleCypher

Inherits:
Object
  • Object
show all
Defined in:
lib/cancancan/active_graph/single_rule_cypher.rb

Overview

Return records for single cancan rule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule, model_class) ⇒ SingleRuleCypher

Returns a new instance of SingleRuleCypher.



8
9
10
11
# File 'lib/cancancan/active_graph/single_rule_cypher.rb', line 8

def initialize(rule, model_class)
  @rule = rule
  @model_class = model_class
end

Instance Attribute Details

#model_classObject (readonly)

Returns the value of attribute model_class.



7
8
9
# File 'lib/cancancan/active_graph/single_rule_cypher.rb', line 7

def model_class
  @model_class
end

#ruleObject (readonly)

Returns the value of attribute rule.



7
8
9
# File 'lib/cancancan/active_graph/single_rule_cypher.rb', line 7

def rule
  @rule
end

Instance Method Details

#recordsObject



13
14
15
16
17
18
# File 'lib/cancancan/active_graph/single_rule_cypher.rb', line 13

def records
  conds = rule.conditions
  return conds if conds.is_a?(::ActiveGraph::Node::Query::QueryProxy) || conds.is_a?(::ActiveGraph::Node::HasN::AssociationProxy)
  return records_for_no_conditions if conds.blank?
  records_for_hash_conditions
end