Class: Banzai::ReferenceParser::IssuableParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/banzai/reference_parser/issuable_parser.rb

Instance Method Summary collapse

Methods inherited from BaseParser

#can?, #collection_cache_key, #collection_objects_for_ids, data_attribute, #find_projects_for_hash_keys, #gather_attributes_per_project, #gather_references, #grouped_objects_for_nodes, #initialize, #nodes_user_can_reference, #process, #project_for_node, #projects_for_nodes, reference_class, #references_relation, #unique_attribute_values

Constructor Details

This class inherits a constructor from Banzai::ReferenceParser::BaseParser

Instance Method Details

#can_read_reference?(user, issuable) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/banzai/reference_parser/issuable_parser.rb', line 22

def can_read_reference?(user, issuable)
  can?(user, "read_#{issuable.class.to_s.underscore}_iid".to_sym, issuable)
end

#nodes_visible_to_user(user, nodes) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/banzai/reference_parser/issuable_parser.rb', line 6

def nodes_visible_to_user(user, nodes)
  records = records_for_nodes(nodes)

  nodes.select do |node|
    issuable = records[node]

    issuable && can_read_reference?(user, issuable)
  end
end

#referenced_by(nodes, options = {}) ⇒ Object



16
17
18
19
20
# File 'lib/banzai/reference_parser/issuable_parser.rb', line 16

def referenced_by(nodes, options = {})
  records = records_for_nodes(nodes)

  nodes.map { |node| records[node] }.compact.uniq
end