Class: Tapioca::Compilers::Dsl::Base
- Inherits:
-
Object
- Object
- Tapioca::Compilers::Dsl::Base
- Extended by:
- T::Helpers, T::Sig
- Includes:
- ParamHelper, Reflection
- Defined in:
- lib/tapioca/compilers/dsl/base.rb
Direct Known Subclasses
AASM, ActionControllerHelpers, ActionMailer, ActiveJob, ActiveModelAttributes, ActiveModelSecurePassword, ActiveRecordAssociations, ActiveRecordColumns, ActiveRecordEnum, ActiveRecordFixtures, ActiveRecordRelations, ActiveRecordScope, ActiveRecordTypedStore, ActiveResource, ActiveStorage, ActiveSupportConcern, ActiveSupportCurrentAttributes, Config, FrozenRecord, IdentityCache, MixedInClassAttributes, Protobuf, RailsGenerators, SidekiqWorker, SmartProperties, StateMachines, UrlHelpers
Constant Summary
Constants included from Reflection
Reflection::ANCESTORS_METHOD, Reflection::CLASS_METHOD, Reflection::CONSTANTS_METHOD, Reflection::EQUAL_METHOD, Reflection::METHOD_METHOD, Reflection::NAME_METHOD, Reflection::OBJECT_ID_METHOD, Reflection::PRIVATE_INSTANCE_METHODS_METHOD, Reflection::PROTECTED_INSTANCE_METHODS_METHOD, Reflection::PUBLIC_INSTANCE_METHODS_METHOD, Reflection::SINGLETON_CLASS_METHOD, Reflection::SUPERCLASS_METHOD
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#processable_constants ⇒ Object
readonly
Returns the value of attribute processable_constants.
Class Method Summary collapse
Instance Method Summary collapse
- #add_error(error) ⇒ Object
- #decorate(tree, constant) ⇒ Object
- #gather_constants ⇒ Object
- #generator_enabled?(generator_name) ⇒ Boolean
- #handles?(constant) ⇒ Boolean
-
#initialize(compiler) ⇒ Base
constructor
A new instance of Base.
Methods included from ParamHelper
#create_block_param, #create_kw_opt_param, #create_kw_param, #create_kw_rest_param, #create_opt_param, #create_param, #create_rest_param, #create_typed_param
Methods included from Reflection
#ancestors_of, #are_equal?, #class_of, #constantize, #constants_of, #descendants_of, #inherited_ancestors_of, #method_of, #name_of, #name_of_type, #object_id_of, #private_instance_methods_of, #protected_instance_methods_of, #public_instance_methods_of, #qualified_name_of, #signature_of, #singleton_class_of, #superclass_of
Constructor Details
#initialize(compiler) ⇒ Base
Returns a new instance of Base.
41 42 43 44 45 46 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 41 def initialize(compiler) @compiler = compiler @processable_constants = T.let(Set.new(gather_constants), T::Set[Module]) @processable_constants.compare_by_identity @errors = T.let([], T::Array[String]) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
25 26 27 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 25 def errors @errors end |
#processable_constants ⇒ Object (readonly)
Returns the value of attribute processable_constants.
22 23 24 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 22 def processable_constants @processable_constants end |
Class Method Details
.resolve(name) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 28 def self.resolve(name) # Try to find built-in tapioca generator first, then globally defined generator. potentials = ["Tapioca::Compilers::Dsl::#{name}", name].map do |potential_name| Object.const_get(potential_name) rescue NameError # Skip if we can't find generator by the potential name nil end potentials.compact.first end |
Instance Method Details
#add_error(error) ⇒ Object
74 75 76 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 74 def add_error(error) @errors << error end |
#decorate(tree, constant) ⇒ Object
67 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 67 def decorate(tree, constant); end |
#gather_constants ⇒ Object
70 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 70 def gather_constants; end |
#generator_enabled?(generator_name) ⇒ Boolean
54 55 56 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 54 def generator_enabled?(generator_name) @compiler.generator_enabled?(generator_name) end |
#handles?(constant) ⇒ Boolean
49 50 51 |
# File 'lib/tapioca/compilers/dsl/base.rb', line 49 def handles?(constant) processable_constants.include?(constant) end |