Class: Banzai::ReferenceParser::SnippetParser

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

Constructor Details

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

Instance Method Details

#nodes_visible_to_user(user, nodes) ⇒ Object

Returns all the nodes that are visible to the given user.



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

def nodes_visible_to_user(user, nodes)
  snippets = lazy { grouped_objects_for_nodes(nodes, references_relation, self.class.data_attribute) }

  nodes.select do |node|
    if node.has_attribute?(self.class.data_attribute)
      can_read_reference?(user, snippets[node])
    else
      true
    end
  end
end

#references_relationObject



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

def references_relation
  Snippet
end