class FactoryBot::AttributeAssigner
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/factory_bot/attribute_assigner.rbs class FactoryBot::AttributeAssigner def alias_names_to_ignore: () -> untyped def attribute_names_to_assign: () -> untyped def attributes_to_set_on_instance: () -> untyped def build_class_instance: () -> Types::Sample def decorated_evaluator: () -> (#<Class:0x0000000111b62b20> | #<Class:0x000000010b1e8848>) type FactoryBot__AttributeAssigner_get_return_value = String | nil | Date | DateTime def get: (Symbol attribute_name) -> FactoryBot__AttributeAssigner_get_return_value def ignorable_alias?: (FactoryBot::Attribute::Dynamic attribute, Symbol override) -> false def ignored_attribute_names: () -> untyped def initialize: ((#<Class:0x0000000110b01f60> | #<Class:0x0000000109852c80>) evaluator, Class build_class, ) -> void type FactoryBot__AttributeAssigner_method_tracking_evaluator_return_value = #<Class:0x0000000111ce2a90> | #<Class:0x00000001107f6ff0> | #<Class:0x0000000114673e90> | #<Class:0x000000010ec35320> | #<Class:0x0000000113430328> | #<Class:0x0000000109852c80> def method_tracking_evaluator: () -> FactoryBot__AttributeAssigner_method_tracking_evaluator_return_value def methods_invoked_on_evaluator: () -> untyped def non_ignored_attribute_names: () -> untyped def object: () -> (Types::Sample | Worker) def override_names: () -> untyped end
@api private
def alias_names_to_ignore
Experimental RBS support (using type sampling data from the type_fusion
project).
def alias_names_to_ignore: () -> untyped
This signature was generated using 2 samples from 1 application.
def alias_names_to_ignore @attribute_list.non_ignored.flat_map { |attribute| override_names.map do |override| attribute.name if ignorable_alias?(attribute, override) end }.compact end
def association_names
def association_names @attribute_list.associations.names end
def attribute_names_to_assign
Experimental RBS support (using type sampling data from the type_fusion
project).
def attribute_names_to_assign: () -> untyped
This signature was generated using 4 samples from 2 applications.
def attribute_names_to_assign @attribute_names_to_assign ||= non_ignored_attribute_names + override_names - ignored_attribute_names - alias_names_to_ignore end
def attributes_to_set_on_hash
def attributes_to_set_on_hash attribute_names_to_assign - association_names end
def attributes_to_set_on_instance
Experimental RBS support (using type sampling data from the type_fusion
project).
def attributes_to_set_on_instance: () -> untyped
This signature was generated using 7 samples from 2 applications.
def attributes_to_set_on_instance (attribute_names_to_assign - @attribute_names_assigned - methods_invoked_on_evaluator).uniq end
def build_class_instance
Experimental RBS support (using type sampling data from the type_fusion
project).
def build_class_instance: () -> Types::Sample
This signature was generated using 4 samples from 1 application.
def build_class_instance @build_class_instance ||= method_tracking_evaluator.instance_exec(&@instance_builder) end
def build_hash
def build_hash @build_hash ||= NullObject.new(hash_instance_methods_to_respond_to) end
def decorated_evaluator
Experimental RBS support (using type sampling data from the type_fusion
project).
def decorated_evaluator: () -> (#<Class:0x0000000111b62b20> | #<Class:0x000000010b1e8848>)
This signature was generated using 2 samples from 1 application.
def decorated_evaluator Decorator::NewConstructor.new( Decorator::InvocationTracker.new(@evaluator), @build_class ) end
def get(attribute_name)
Experimental RBS support (using type sampling data from the type_fusion
project).
type FactoryBot__AttributeAssigner_get_return_value = String | nil | Date | DateTime def get: (Symbol attribute_name) -> FactoryBot__AttributeAssigner_get_return_value
This signature was generated using 26 samples from 2 applications.
def get(attribute_name) @evaluator.send(attribute_name) end
def hash
def hash @evaluator.instance = build_hash attributes_to_set_on_hash.each_with_object({}) do |attribute, result| result[attribute] = get(attribute) end end
def hash_instance_methods_to_respond_to
def hash_instance_methods_to_respond_to @attribute_list.names + override_names + @build_class.instance_methods end
def ignorable_alias?(attribute, override)
Experimental RBS support (using type sampling data from the type_fusion
project).
def ignorable_alias?: (FactoryBot::Attribute::Dynamic attribute, Symbol override) -> false
This signature was generated using 129 samples from 1 application.
def ignorable_alias?(attribute, override) attribute.alias_for?(override) && attribute.name != override && !ignored_attribute_names.include?(override) end
def ignored_attribute_names
Experimental RBS support (using type sampling data from the type_fusion
project).
def ignored_attribute_names: () -> untyped
This signature was generated using 1 sample from 1 application.
def ignored_attribute_names @attribute_list.ignored.names end
def initialize(evaluator, build_class, &instance_builder)
Experimental RBS support (using type sampling data from the type_fusion
project).
def initialize: ((#<Class:0x0000000110b01f60> | #<Class:0x0000000109852c80>) evaluator, Class build_class, ) -> void
This signature was generated using 2 samples from 2 applications.
def initialize(evaluator, build_class, &instance_builder) @build_class = build_class @instance_builder = instance_builder @evaluator = evaluator @attribute_list = evaluator.class.attribute_list @attribute_names_assigned = [] end
def method_tracking_evaluator
Experimental RBS support (using type sampling data from the type_fusion
project).
type FactoryBot__AttributeAssigner_method_tracking_evaluator_return_value = #<Class:0x0000000111ce2a90> | #<Class:0x00000001107f6ff0> | #<Class:0x0000000114673e90> | #<Class:0x000000010ec35320> | #<Class:0x0000000113430328> | #<Class:0x0000000109852c80> def method_tracking_evaluator: () -> FactoryBot__AttributeAssigner_method_tracking_evaluator_return_value
This signature was generated using 6 samples from 2 applications.
def method_tracking_evaluator @method_tracking_evaluator ||= Decorator::AttributeHash.new( decorated_evaluator, attribute_names_to_assign ) end
def methods_invoked_on_evaluator
Experimental RBS support (using type sampling data from the type_fusion
project).
def methods_invoked_on_evaluator: () -> untyped
This signature was generated using 4 samples from 1 application.
def methods_invoked_on_evaluator method_tracking_evaluator.__invoked_methods__ end
def non_ignored_attribute_names
Experimental RBS support (using type sampling data from the type_fusion
project).
def non_ignored_attribute_names: () -> untyped
This signature was generated using 2 samples from 1 application.
def non_ignored_attribute_names @attribute_list.non_ignored.names end
def object
Experimental RBS support (using type sampling data from the type_fusion
project).
def object: () -> (Types::Sample | Worker)
This signature was generated using 2 samples from 2 applications.
def object @evaluator.instance = build_class_instance build_class_instance.tap do |instance| attributes_to_set_on_instance.each do |attribute| instance.public_send("#{attribute}=", get(attribute)) @attribute_names_assigned << attribute end end end
def override_names
Experimental RBS support (using type sampling data from the type_fusion
project).
def override_names: () -> untyped
This signature was generated using 28 samples from 2 applications.
def override_names @evaluator.__override_names__ end