class HQ::GraphQL::ObjectAssociation::ResourceReflection

Attributes

block[R]
macro[R]
name[R]
options[R]
scope[R]

Public Class Methods

new(name, scope, options, macro, block) click to toggle source
# File lib/hq/graphql/object_association.rb, line 41
def initialize(name, scope, options, macro, block)
  @name = name
  @scope = scope
  @options = options
  @macro = macro
  @block = block
end

Public Instance Methods

reflection(model_klass) click to toggle source
# File lib/hq/graphql/object_association.rb, line 49
def reflection(model_klass)
  if macro == :has_many
    ::ActiveRecord::Associations::Builder::HasMany.create_reflection(model_klass, name, scope, options)
  elsif macro == :belongs_to
    ::ActiveRecord::Associations::Builder::BelongsTo.create_reflection(model_klass, name, scope, options)
  end
end