Sha256: 47ef3ecaf9fe27ac7d66b520b0b67528772460cdc05ca4335ef1d0704120c8fb
Contents?: true
Size: 734 Bytes
Versions: 2
Compression:
Stored size: 734 Bytes
Contents
module CypherBuilder class MicroResolver < Struct.new(:payload, :context) include Resolver def execute(value) resolve(value, payload: payload, context: context) end end def OrderBy(first, *rest) OrderBy.new(first, *rest) end class OrderBy include Resolver def initialize(first, *rest) @parts = wrap(*([first] + rest)) end def as_cypher(payload:, context:) rsv = MicroResolver.new(payload, context.add(self)) ps = @parts.reduce([]) do |r, v| if r.last && AsIs === v r[0..-2] + [[r.last, rsv.execute(v)].join(' ')] else r + [rsv.execute(v)] end end sprintf('ORDER BY %s', ps.join(', ')) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cypher_builder-0.0.5 | lib/cypher_builder/order_by.rb |
cypher_builder-0.0.4 | lib/cypher_builder/order_by.rb |