Class: RbsActiverecord::Generator
- Inherits:
-
Object
- Object
- RbsActiverecord::Generator
- Includes:
- Utils
- Defined in:
- lib/rbs_activerecord/generator.rb,
lib/rbs_activerecord/generator/scopes.rb,
lib/rbs_activerecord/generator/enum/base.rb,
lib/rbs_activerecord/generator/attributes.rb,
lib/rbs_activerecord/generator/enum/scopes.rb,
lib/rbs_activerecord/generator/associations.rb,
lib/rbs_activerecord/generator/enum/mappings.rb,
lib/rbs_activerecord/generator/pluck_overloads.rb,
lib/rbs_activerecord/generator/secure_password.rb,
lib/rbs_activerecord/generator/active_storage/scopes.rb,
lib/rbs_activerecord/generator/delegated_type/scopes.rb,
lib/rbs_activerecord/generator/enum/instance_methods.rb,
lib/rbs_activerecord/generator/active_storage/instance_methods.rb,
lib/rbs_activerecord/generator/delegated_type/instance_methods.rb
Overview
rubocop:disable Metrics/ClassLength
Defined Under Namespace
Modules: ActiveStorage, DelegatedType, Enum Classes: Associations, Attributes, PluckOverloads, Scopes, SecurePassword
Instance Attribute Summary collapse
-
#klass ⇒ Object
readonly
: singleton(ActiveRecord::Base).
-
#klass_name ⇒ Object
readonly
: String.
-
#model ⇒ Object
readonly
: RbsActiverecord::Model.
Instance Method Summary collapse
-
#generate ⇒ Object
: String # rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#initialize(klass) ⇒ Generator
constructor
A new instance of Generator.
Methods included from Utils
#format, #primary_key_type_for, #sql_type_to_class
Constructor Details
Instance Attribute Details
#klass ⇒ Object (readonly)
: singleton(ActiveRecord::Base)
9 10 11 |
# File 'lib/rbs_activerecord/generator.rb', line 9 def klass @klass end |
#klass_name ⇒ Object (readonly)
: String
10 11 12 |
# File 'lib/rbs_activerecord/generator.rb', line 10 def klass_name @klass_name end |
#model ⇒ Object (readonly)
: RbsActiverecord::Model
11 12 13 |
# File 'lib/rbs_activerecord/generator.rb', line 11 def model @model end |
Instance Method Details
#generate ⇒ Object
: String # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rbs_activerecord/generator.rb', line 20 def generate #: String # rubocop:disable Metrics/AbcSize, Metrics/MethodLength format <<~RBS #{header} #{Attributes.new(model).generate} #{Associations.new(model).generate} #{ActiveStorage::InstanceMethods.new(model).generate} #{ActiveStorage::Scopes.new(model).generate} #{PluckOverloads.new(model).generate} #{SecurePassword.new(model).generate} #{DelegatedType::InstanceMethods.new(model, declarations).generate} #{DelegatedType::Scopes.new(model, declarations).generate} #{Enum::InstanceMethods.new(model, declarations).generate} #{Enum::Mappings.new(model, declarations).generate} #{Enum::Scopes.new(model, declarations).generate} #{Scopes.new(model, declarations).generate} module GeneratedCollectionProxyInstanceMethods[Model, PrimaryKey] def build: (?ActiveRecord::Associations::CollectionProxy::_EachPair attributes) ?{ () -> untyped } -> Model | (Array[ActiveRecord::Associations::CollectionProxy::_EachPair] attributes) ?{ () -> untyped } -> Array[Model] def create: (?ActiveRecord::Associations::CollectionProxy::_EachPair attributes) ?{ () -> untyped } -> Model | (Array[ActiveRecord::Associations::CollectionProxy::_EachPair] attributes) ?{ () -> untyped } -> Array[Model] def create!: (?ActiveRecord::Associations::CollectionProxy::_EachPair attributes) ?{ () -> untyped } -> Model | (Array[ActiveRecord::Associations::CollectionProxy::_EachPair] attributes) ?{ () -> untyped } -> Array[Model] def reload: () -> Array[Model] def replace: (Array[Model]) -> void def delete: (*Model | PrimaryKey) -> Array[Model] def destroy: (*Model | PrimaryKey) -> Array[Model] def <<: (*Model | Array[Model]) -> self def prepend: (*Model | Array[Model]) -> self end class ActiveRecord_Relation < ::ActiveRecord::Relation include ::Enumerable[#{klass_name}] include ::ActiveRecord::Relation::Methods[#{klass_name}, #{primary_key_type}] #{relation_methods} include GeneratedPluckOverloads end class ActiveRecord_Associations_CollectionProxy < ::ActiveRecord::Associations::CollectionProxy include ::Enumerable[#{klass_name}] include ::ActiveRecord::Relation::Methods[#{klass_name}, #{primary_key_type}] #{relation_methods} include GeneratedPluckOverloads include GeneratedCollectionProxyInstanceMethods[#{klass_name}, #{primary_key_type}] end extend ::ActiveRecord::Base::ClassMethods[#{klass_name}, #{klass_name}::ActiveRecord_Relation, #{primary_key_type}] #{scope_class_methods} extend GeneratedEnumMappingMethods extend GeneratedPluckOverloads include GeneratedActiveStorageInstanceMethods include GeneratedAttributeMethods include GeneratedAssociationMethods include GeneratedDelegatedTypeInstanceMethods include GeneratedEnumInstanceMethods include GeneratedSecurePasswordMethods #{} RBS end |