Sha256: 2744ef5edcb610d714c94ffcd12f0a40ee364f25a3f7445f6cf99e45577a0172
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require 'forwardable' require_relative './null_node' module DynamoidAdvancedWhere module Nodes class RootNode < BaseNode extend Forwardable attr_accessor :klass, :child_node def initialize(klass:, &blk) self.klass = klass evaluate_block(blk) if blk self.child_node ||= AndNode.new freeze end def method_missing(method, *args, &blk) if allowed_field?(method) FieldNode.create_node(attr_config: klass.attributes[method], field_path: method) else super end end def respond_to_missing?(method, _i) allowed_field?(method) end def allowed_field?(method) klass.attributes.key?(method.to_sym) end private def evaluate_block(blk) self.child_node = if blk.arity.zero? Dynamoid.logger.warn 'Using DynamoidAdvancedWhere builder without an argument is now deprecated' instance_eval(&blk) else blk.call(self) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems