Class: ActiveGraph::Core::QueryClauses::CreateClause

Inherits:
Clause
  • Object
show all
Defined in:
lib/active_graph/core/query_clauses.rb

Direct Known Subclasses

CreateUniqueClause, MergeClause

Constant Summary collapse

KEYWORD =
'CREATE'

Constants inherited from Clause

ActiveGraph::Core::QueryClauses::Clause::AND, ActiveGraph::Core::QueryClauses::Clause::COMMA_SPACE, ActiveGraph::Core::QueryClauses::Clause::PRETTY_NEW_LINE, ActiveGraph::Core::QueryClauses::Clause::UNDERSCORE

Instance Attribute Summary

Attributes inherited from Clause

#arg, #options, #param_vars_added, #params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Clause

#_nested_value_hash?, #_use_key_for_var?, #add_param, #add_params, #attributes_from_key_and_value, clause_string, final_keyword, from_arg, from_args, from_key_and_single_value, #initialize, keyword, keyword_downcase, #label_from_key_and_value, #node_from_key_and_value, paramaterize_key!, to_cypher, #value, #var_from_key_and_value

Constructor Details

This class inherits a constructor from ActiveGraph::Core::QueryClauses::Clause

Class Method Details

.clause_colorObject



510
511
512
# File 'lib/active_graph/core/query_clauses.rb', line 510

def clause_color
  ANSI::GREEN
end

.clause_joinObject



506
507
508
# File 'lib/active_graph/core/query_clauses.rb', line 506

def clause_join
  ', '
end

.clause_strings(clauses) ⇒ Object



502
503
504
# File 'lib/active_graph/core/query_clauses.rb', line 502

def clause_strings(clauses)
  clauses.map!(&:value)
end

Instance Method Details

#from_hash(hash) ⇒ Object



487
488
489
490
491
492
493
494
495
# File 'lib/active_graph/core/query_clauses.rb', line 487

def from_hash(hash)
  if hash.values.any? { |value| value.is_a?(Hash) }
    hash.map do |key, value|
      from_key_and_value(key, value)
    end
  else
    "(#{attributes_string(hash)})"
  end
end

#from_key_and_value(key, value) ⇒ Object



497
498
499
# File 'lib/active_graph/core/query_clauses.rb', line 497

def from_key_and_value(key, value)
  node_from_key_and_value(key, value, prefer: :label)
end

#from_string(value) ⇒ Object



479
480
481
# File 'lib/active_graph/core/query_clauses.rb', line 479

def from_string(value)
  value
end

#from_symbol(value) ⇒ Object



483
484
485
# File 'lib/active_graph/core/query_clauses.rb', line 483

def from_symbol(value)
  "(:#{value})"
end