Class: Tapioca::Compilers::Dsl::ActiveRecordScope

Inherits:
Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/compilers/dsl/active_record_scope.rb

Overview

sig { params(args: T.untyped, blk: T.untyped).returns(T.untyped) }

def public_kind(*args, &blk); end

end ~~~

Instance Attribute Summary

Attributes inherited from Base

#processable_constants

Instance Method Summary collapse

Methods inherited from Base

#handles?, #initialize

Constructor Details

This class inherits a constructor from Tapioca::Compilers::Dsl::Base

Instance Method Details

#decorate(root, constant) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/tapioca/compilers/dsl/active_record_scope.rb', line 54

def decorate(root, constant)
  scope_method_names = constant.send(:generated_relation_methods).instance_methods(false)
  return if scope_method_names.empty?

  module_name = "#{constant}::GeneratedRelationMethods"
  root.create_module(module_name) do |mod|
    scope_method_names.each do |scope_method|
      generate_scope_method(scope_method, mod)
    end
  end

  root.path(constant) do |k|
    k.create_extend(module_name)
  end
end

#gather_constantsObject



71
72
73
# File 'lib/tapioca/compilers/dsl/active_record_scope.rb', line 71

def gather_constants
  ::ActiveRecord::Base.descendants.reject(&:abstract_class?)
end