Class: RbsActivesupport::DeclarationBuilder

Inherits:
Object
  • Object
show all
Includes:
AST
Defined in:
lib/rbs_activesupport/declaration_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AST

#eval_args_with_options, #eval_include_args, #eval_node

Constructor Details

#initialize(resolver, method_searcher) ⇒ DeclarationBuilder

Returns a new instance of DeclarationBuilder.



15
16
17
18
19
# File 'lib/rbs_activesupport/declaration_builder.rb', line 15

def initialize(resolver, method_searcher) #: void
  @resolver = resolver
  @method_searcher = method_searcher
  @included_modules = []
end

Instance Attribute Details

#included_modulesObject (readonly)

: Array



11
12
13
# File 'lib/rbs_activesupport/declaration_builder.rb', line 11

def included_modules
  @included_modules
end

#method_searcherObject (readonly)

: MethodSearcher



10
11
12
# File 'lib/rbs_activesupport/declaration_builder.rb', line 10

def method_searcher
  @method_searcher
end

#resolverObject (readonly)

: RBS::Resolver::TypeNameResolver



9
10
11
# File 'lib/rbs_activesupport/declaration_builder.rb', line 9

def resolver
  @resolver
end

Instance Method Details

#build(namespace, method_calls, context = nil) ⇒ Object



24
25
26
27
28
29
# File 'lib/rbs_activesupport/declaration_builder.rb', line 24

def build(namespace, method_calls, context = nil) #: [Array[String], Array[String]]
  built = build_method_calls(namespace, method_calls, context)
  public_decls, private_decls = built.partition(&:public?)
  [public_decls.map { |decl| render(namespace, decl) },
   private_decls.map { |decl| render(namespace, decl) }]
end