Class: Rails::Annotate::Solargraph::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/annotate/solargraph/scope.rb

Overview

Represents a scope on an ActiveRecord Model.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, model_class:, proc_parameters:, definition:) ⇒ Scope

Returns a new instance of Scope.

Parameters:

  • name (Symbol)
  • model_class (Class)
  • proc_parameters (Array<Symbol>)
  • definition (String)


21
22
23
24
25
26
27
# File 'lib/rails/annotate/solargraph/scope.rb', line 21

def initialize(name:, model_class:, proc_parameters:, definition:)
  @name = name
  @model_class = model_class
  @proc_parameters = proc_parameters
  @definition = definition
  freeze
end

Instance Attribute Details

#definitionObject (readonly)

Parameters:

  • definition (String)


15
16
17
# File 'lib/rails/annotate/solargraph/scope.rb', line 15

def definition
  @definition
end

#model_classObject (readonly)

Parameters:

  • model_class (Class)


11
12
13
# File 'lib/rails/annotate/solargraph/scope.rb', line 11

def model_class
  @model_class
end

#nameObject (readonly)

Parameters:

  • name (Symbol)


9
10
11
# File 'lib/rails/annotate/solargraph/scope.rb', line 9

def name
  @name
end

#proc_parametersObject (readonly)

Parameters:

  • proc_parameters (Array<Symbol>)


13
14
15
# File 'lib/rails/annotate/solargraph/scope.rb', line 13

def proc_parameters
  @proc_parameters
end

Instance Method Details

#documentationString

Returns:

  • (String)


30
31
32
33
34
35
36
37
38
39
# File 'lib/rails/annotate/solargraph/scope.rb', line 30

def documentation
  <<~DOC
    #     # Scope `#{@name.inspect}`.
    #     #
    #{documented_definition}
    #     #
    #     # @return [Array<#{@model_class}>, nil]
    #     #{signature}
  DOC
end