Class: Banzai::ReferenceParser::DesignParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/banzai/reference_parser/design_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, #referenced_by, #unique_attribute_values

Constructor Details

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

Instance Method Details

#issues_for_nodes(nodes) ⇒ Object


25
26
27
28
# File 'lib/banzai/reference_parser/design_parser.rb', line 25

def issues_for_nodes(nodes)
  relation = Issue.includes(project: [:project_feature])
  grouped_objects_for_nodes(nodes, relation, 'data-issue')
end

#nodes_visible_to_user(user, nodes) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/banzai/reference_parser/design_parser.rb', line 12

def nodes_visible_to_user(user, nodes)
  issues = issues_for_nodes(nodes)
  issue_attr = 'data-issue'

  nodes.select do |node|
    if node.has_attribute?(issue_attr)
      can?(user, :read_design, issues[node])
    else
      true
    end
  end
end

#references_relationObject


8
9
10
# File 'lib/banzai/reference_parser/design_parser.rb', line 8

def references_relation
  DesignManagement::Design
end