Class: RbsDiscard::Discard::Generator
- Inherits:
-
Object
- Object
- RbsDiscard::Discard::Generator
- Defined in:
- lib/rbs_discard/discard.rb
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#klass_name ⇒ Object
readonly
Returns the value of attribute klass_name.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(klass) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(klass) ⇒ Generator
Returns a new instance of Generator.
22 23 24 25 |
# File 'lib/rbs_discard/discard.rb', line 22 def initialize(klass) @klass = klass @klass_name = klass.name || "" end |
Instance Attribute Details
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
20 21 22 |
# File 'lib/rbs_discard/discard.rb', line 20 def klass @klass end |
#klass_name ⇒ Object (readonly)
Returns the value of attribute klass_name.
20 21 22 |
# File 'lib/rbs_discard/discard.rb', line 20 def klass_name @klass_name end |
Instance Method Details
#generate ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rbs_discard/discard.rb', line 27 def generate format <<~RBS #{header} class ActiveRecord_Relation include Discard::Model::Relation end class ActiveRecord_Associations_CollectionProxy include Discard::Model::Relation end include Discard::Model extend Discard::Model::ClassMethods def self.kept: () -> #{klass_name}::ActiveRecord_Relation def self.undiscarded: () -> #{klass_name}::ActiveRecord_Relation def self.discarded: () -> #{klass_name}::ActiveRecord_Relation def self.with_discarded: () -> #{klass_name}::ActiveRecord_Relation #{} RBS end |