Class: RbsActiverecord::Generator::Scopes
- Inherits:
-
Object
- Object
- RbsActiverecord::Generator::Scopes
- Defined in:
- lib/rbs_activerecord/generator/scopes.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
: Array.
-
#model ⇒ Object
readonly
: RbsActiverecord::Model.
Instance Method Summary collapse
-
#generate ⇒ Object
: String.
-
#initialize(model, declarations) ⇒ Scopes
constructor
A new instance of Scopes.
Constructor Details
#initialize(model, declarations) ⇒ Scopes
Returns a new instance of Scopes.
11 12 13 14 |
# File 'lib/rbs_activerecord/generator/scopes.rb', line 11 def initialize(model, declarations) #: void @model = model @declarations = declarations.fetch(model.klass.name, []) end |
Instance Attribute Details
#declarations ⇒ Object (readonly)
: Array
7 8 9 |
# File 'lib/rbs_activerecord/generator/scopes.rb', line 7 def declarations @declarations end |
#model ⇒ Object (readonly)
: RbsActiverecord::Model
6 7 8 |
# File 'lib/rbs_activerecord/generator/scopes.rb', line 6 def model @model end |
Instance Method Details
#generate ⇒ Object
: String
16 17 18 19 20 21 22 |
# File 'lib/rbs_activerecord/generator/scopes.rb', line 16 def generate #: String <<~RBS.strip module GeneratedScopeMethods[Relation] #{scopes.map { |node| scope(node) }.join("\n")} end RBS end |