Module: NQL::Syntax::Boolean1

Defined in:
lib/nql/grammar.rb

Instance Method Summary collapse

Instance Method Details

#is_node?(node_type) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/nql/grammar.rb', line 80

def is_node?(node_type)
  node_type.to_sym == :boolean
end

#to_ransackObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/nql/grammar.rb', line 65

def to_ransack
  group = {g: [{m: coordinator.to_ransack}]}

  [left, right].each do |side|
    if side.is_node?(:boolean)
      group[:g][0].merge! side.to_ransack
    else
      group[:g][0][:c] ||= []
      group[:g][0][:c] << side.to_ransack
    end
  end

  group
end