-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy pathactivemodel@7.1.3.4.rbi
6661 lines (5845 loc) · 220 KB
/
activemodel@7.1.3.4.rbi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# typed: true
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `activemodel` gem.
# Please instead update this file by running `bin/tapioca gem activemodel`.
# :include: activemodel/README.rdoc
#
# source://activemodel//lib/active_model/gem_version.rb#3
module ActiveModel
extend ::ActiveSupport::Autoload
class << self
# source://activemodel//lib/active_model/deprecator.rb#4
def deprecator; end
# source://activemodel//lib/active_model.rb#76
def eager_load!; end
# Returns the currently loaded version of \Active \Model as a +Gem::Version+.
#
# source://activemodel//lib/active_model/gem_version.rb#5
def gem_version; end
# Returns the currently loaded version of \Active \Model as a +Gem::Version+.
#
# source://activemodel//lib/active_model/version.rb#7
def version; end
end
end
# = Active \Model \API
#
# Includes the required interface for an object to interact with
# Action Pack and Action View, using different Active \Model modules.
# It includes model name introspections, conversions, translations, and
# validations. Besides that, it allows you to initialize the object with a
# hash of attributes, pretty much like Active Record does.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::API
# attr_accessor :name, :age
# end
#
# person = Person.new(name: 'bob', age: '18')
# person.name # => "bob"
# person.age # => "18"
#
# Note that, by default, +ActiveModel::API+ implements #persisted?
# to return +false+, which is the most common case. You may want to override
# it in your class to simulate a different scenario:
#
# class Person
# include ActiveModel::API
# attr_accessor :id, :name
#
# def persisted?
# self.id.present?
# end
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.persisted? # => true
#
# Also, if for some reason you need to run code on initialize ( ::new ), make
# sure you call +super+ if you want the attributes hash initialization to
# happen.
#
# class Person
# include ActiveModel::API
# attr_accessor :id, :name, :omg
#
# def initialize(attributes={})
# super
# @omg ||= true
# end
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.omg # => true
#
# For more detailed information on other functionalities available, please
# refer to the specific modules included in +ActiveModel::API+
# (see below).
#
# source://activemodel//lib/active_model/api.rb#59
module ActiveModel::API
include ::ActiveModel::ForbiddenAttributesProtection
include ::ActiveModel::AttributeAssignment
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
include ::ActiveSupport::Callbacks
include ::ActiveModel::Validations::HelperMethods
include ::ActiveModel::Validations
include ::ActiveModel::Conversion
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::Validations::ClassMethods
mixes_in_class_methods ::ActiveModel::Callbacks
mixes_in_class_methods ::ActiveSupport::Callbacks::ClassMethods
mixes_in_class_methods ::ActiveSupport::DescendantsTracker
mixes_in_class_methods ::ActiveModel::Translation
mixes_in_class_methods ::ActiveModel::Validations::HelperMethods
mixes_in_class_methods ::ActiveModel::Conversion::ClassMethods
# Initializes a new model with the given +params+.
#
# class Person
# include ActiveModel::API
# attr_accessor :name, :age
# end
#
# person = Person.new(name: 'bob', age: '18')
# person.name # => "bob"
# person.age # => "18"
#
# source://activemodel//lib/active_model/api.rb#80
def initialize(attributes = T.unsafe(nil)); end
# Indicates if the model is persisted. Default is +false+.
#
# class Person
# include ActiveModel::API
# attr_accessor :id, :name
# end
#
# person = Person.new(id: 1, name: 'bob')
# person.persisted? # => false
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/api.rb#95
def persisted?; end
module GeneratedClassMethods
def __callbacks; end
def __callbacks=(value); end
def __callbacks?; end
def _validators; end
def _validators=(value); end
def _validators?; end
def param_delimiter; end
def param_delimiter=(value); end
def param_delimiter?; end
end
module GeneratedInstanceMethods
def __callbacks; end
def __callbacks?; end
def _validators; end
def _validators?; end
def param_delimiter=(value); end
end
end
# source://activemodel//lib/active_model/access.rb#7
module ActiveModel::Access
# source://activemodel//lib/active_model/access.rb#8
def slice(*methods); end
# source://activemodel//lib/active_model/access.rb#12
def values_at(*methods); end
end
# source://activemodel//lib/active_model/attribute.rb#6
class ActiveModel::Attribute
# This method should not be called directly.
# Use #from_database or #from_user
#
# @return [Attribute] a new instance of Attribute
#
# source://activemodel//lib/active_model/attribute.rb#33
def initialize(name, value_before_type_cast, type, original_attribute = T.unsafe(nil), value = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute.rb#115
def ==(other); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#107
def came_from_user?; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#66
def changed?; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#70
def changed_in_place?; end
# source://activemodel//lib/active_model/attribute.rb#135
def encode_with(coder); end
# source://activemodel//lib/active_model/attribute.rb#115
def eql?(other); end
# source://activemodel//lib/active_model/attribute.rb#74
def forgetting_assignment; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#111
def has_been_read?; end
# source://activemodel//lib/active_model/attribute.rb#123
def hash; end
# source://activemodel//lib/active_model/attribute.rb#127
def init_with(coder); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#103
def initialized?; end
# Returns the value of attribute name.
#
# source://activemodel//lib/active_model/attribute.rb#29
def name; end
# source://activemodel//lib/active_model/attribute.rb#47
def original_value; end
# source://activemodel//lib/active_model/attribute.rb#143
def original_value_for_database; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#62
def serializable?(&block); end
# Returns the value of attribute type.
#
# source://activemodel//lib/active_model/attribute.rb#29
def type; end
# @raise [NotImplementedError]
#
# source://activemodel//lib/active_model/attribute.rb#99
def type_cast(*_arg0); end
# source://activemodel//lib/active_model/attribute.rb#41
def value; end
# Returns the value of attribute value_before_type_cast.
#
# source://activemodel//lib/active_model/attribute.rb#29
def value_before_type_cast; end
# source://activemodel//lib/active_model/attribute.rb#55
def value_for_database; end
# source://activemodel//lib/active_model/attribute.rb#87
def with_cast_value(value); end
# source://activemodel//lib/active_model/attribute.rb#91
def with_type(type); end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#7
def with_user_default(value); end
# source://activemodel//lib/active_model/attribute.rb#83
def with_value_from_database(value); end
# source://activemodel//lib/active_model/attribute.rb#78
def with_value_from_user(value); end
private
# source://activemodel//lib/active_model/attribute.rb#169
def _original_value_for_database; end
# source://activemodel//lib/active_model/attribute.rb#165
def _value_for_database; end
# Returns the value of attribute original_attribute.
#
# source://activemodel//lib/active_model/attribute.rb#152
def assigned?; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#161
def changed_from_assignment?; end
# source://activemodel//lib/active_model/attribute.rb#155
def initialize_dup(other); end
# Returns the value of attribute original_attribute.
#
# source://activemodel//lib/active_model/attribute.rb#152
def original_attribute; end
class << self
# source://activemodel//lib/active_model/attribute.rb#8
def from_database(name, value_before_type_cast, type, value = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute.rb#12
def from_user(name, value_before_type_cast, type, original_attribute = T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute.rb#20
def null(name); end
# source://activemodel//lib/active_model/attribute.rb#24
def uninitialized(name, type); end
# source://activemodel//lib/active_model/attribute.rb#16
def with_cast_value(name, value_before_type_cast, type); end
end
end
# source://activemodel//lib/active_model/attribute.rb#173
class ActiveModel::Attribute::FromDatabase < ::ActiveModel::Attribute
# source://activemodel//lib/active_model/attribute.rb#178
def forgetting_assignment; end
# source://activemodel//lib/active_model/attribute.rb#174
def type_cast(value); end
private
# source://activemodel//lib/active_model/attribute.rb#192
def _original_value_for_database; end
end
# source://activemodel//lib/active_model/attribute.rb#197
class ActiveModel::Attribute::FromUser < ::ActiveModel::Attribute
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#202
def came_from_user?; end
# source://activemodel//lib/active_model/attribute.rb#198
def type_cast(value); end
private
# source://activemodel//lib/active_model/attribute.rb#207
def _value_for_database; end
end
# source://activemodel//lib/active_model/attribute.rb#222
class ActiveModel::Attribute::Null < ::ActiveModel::Attribute
# @return [Null] a new instance of Null
#
# source://activemodel//lib/active_model/attribute.rb#223
def initialize(name); end
# source://activemodel//lib/active_model/attribute.rb#227
def type_cast(*_arg0); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute.rb#235
def with_cast_value(value); end
# source://activemodel//lib/active_model/attribute.rb#231
def with_type(type); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute.rb#235
def with_value_from_database(value); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute.rb#235
def with_value_from_user(value); end
end
# source://activemodel//lib/active_model/attribute.rb#242
class ActiveModel::Attribute::Uninitialized < ::ActiveModel::Attribute
# @return [Uninitialized] a new instance of Uninitialized
#
# source://activemodel//lib/active_model/attribute.rb#245
def initialize(name, type); end
# source://activemodel//lib/active_model/attribute.rb#266
def forgetting_assignment; end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#262
def initialized?; end
# source://activemodel//lib/active_model/attribute.rb#255
def original_value; end
# source://activemodel//lib/active_model/attribute.rb#249
def value; end
# source://activemodel//lib/active_model/attribute.rb#259
def value_for_database; end
# source://activemodel//lib/active_model/attribute.rb#270
def with_type(type); end
end
# source://activemodel//lib/active_model/attribute.rb#243
ActiveModel::Attribute::Uninitialized::UNINITIALIZED_ORIGINAL_VALUE = T.let(T.unsafe(nil), Object)
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#11
class ActiveModel::Attribute::UserProvidedDefault < ::ActiveModel::Attribute::FromUser
# @return [UserProvidedDefault] a new instance of UserProvidedDefault
#
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#12
def initialize(name, value, type, database_default); end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#29
def marshal_dump; end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#40
def marshal_load(values); end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#17
def value_before_type_cast; end
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#25
def with_type(type); end
private
# Returns the value of attribute user_provided_value.
#
# source://activemodel//lib/active_model/attribute/user_provided_default.rb#52
def user_provided_value; end
end
# source://activemodel//lib/active_model/attribute.rb#212
class ActiveModel::Attribute::WithCastValue < ::ActiveModel::Attribute
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute.rb#217
def changed_in_place?; end
# source://activemodel//lib/active_model/attribute.rb#213
def type_cast(value); end
end
# source://activemodel//lib/active_model/attribute_assignment.rb#6
module ActiveModel::AttributeAssignment
include ::ActiveModel::ForbiddenAttributesProtection
# Allows you to set all the attributes by passing in a hash of attributes with
# keys matching the attribute names.
#
# If the passed hash responds to <tt>permitted?</tt> method and the return value
# of this method is +false+ an ActiveModel::ForbiddenAttributesError
# exception is raised.
#
# class Cat
# include ActiveModel::AttributeAssignment
# attr_accessor :name, :status
# end
#
# cat = Cat.new
# cat.assign_attributes(name: "Gorby", status: "yawning")
# cat.name # => 'Gorby'
# cat.status # => 'yawning'
# cat.assign_attributes(status: "sleeping")
# cat.name # => 'Gorby'
# cat.status # => 'sleeping'
#
# source://activemodel//lib/active_model/attribute_assignment.rb#28
def assign_attributes(new_attributes); end
# Allows you to set all the attributes by passing in a hash of attributes with
# keys matching the attribute names.
#
# If the passed hash responds to <tt>permitted?</tt> method and the return value
# of this method is +false+ an ActiveModel::ForbiddenAttributesError
# exception is raised.
#
# class Cat
# include ActiveModel::AttributeAssignment
# attr_accessor :name, :status
# end
#
# cat = Cat.new
# cat.assign_attributes(name: "Gorby", status: "yawning")
# cat.name # => 'Gorby'
# cat.status # => 'yawning'
# cat.assign_attributes(status: "sleeping")
# cat.name # => 'Gorby'
# cat.status # => 'sleeping'
#
# source://activemodel//lib/active_model/attribute_assignment.rb#28
def attributes=(new_attributes); end
private
# source://activemodel//lib/active_model/attribute_assignment.rb#46
def _assign_attribute(k, v); end
# source://activemodel//lib/active_model/attribute_assignment.rb#40
def _assign_attributes(attributes); end
end
# = Active \Model \Attribute \Methods
#
# Provides a way to add prefixes and suffixes to your methods as
# well as handling the creation of ActiveRecord::Base - like
# class methods such as +table_name+.
#
# The requirements to implement +ActiveModel::AttributeMethods+ are to:
#
# * <tt>include ActiveModel::AttributeMethods</tt> in your class.
# * Call each of its methods you want to add, such as +attribute_method_suffix+
# or +attribute_method_prefix+.
# * Call +define_attribute_methods+ after the other methods are called.
# * Define the various generic +_attribute+ methods that you have declared.
# * Define an +attributes+ method which returns a hash with each
# attribute name in your model as hash key and the attribute value as hash value.
# Hash keys must be strings.
#
# A minimal implementation could be:
#
# class Person
# include ActiveModel::AttributeMethods
#
# attribute_method_affix prefix: 'reset_', suffix: '_to_default!'
# attribute_method_suffix '_contrived?'
# attribute_method_prefix 'clear_'
# define_attribute_methods :name
#
# attr_accessor :name
#
# def attributes
# { 'name' => @name }
# end
#
# private
# def attribute_contrived?(attr)
# true
# end
#
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
#
# def reset_attribute_to_default!(attr)
# send("#{attr}=", 'Default Name')
# end
# end
#
# source://activemodel//lib/active_model/attribute_methods.rb#64
module ActiveModel::AttributeMethods
extend ::ActiveSupport::Concern
include GeneratedInstanceMethods
mixes_in_class_methods GeneratedClassMethods
mixes_in_class_methods ::ActiveModel::AttributeMethods::ClassMethods
# +attribute_missing+ is like +method_missing+, but for attributes. When
# +method_missing+ is called we check to see if there is a matching
# attribute method. If so, we tell +attribute_missing+ to dispatch the
# attribute. This method can be overloaded to customize the behavior.
#
# source://activemodel//lib/active_model/attribute_methods.rb#498
def attribute_missing(match, *args, **_arg2, &block); end
# Allows access to the object attributes, which are held in the hash
# returned by <tt>attributes</tt>, as though they were first-class
# methods. So a +Person+ class with a +name+ attribute can for example use
# <tt>Person#name</tt> and <tt>Person#name=</tt> and never directly use
# the attributes hash -- except for multiple assignments with
# <tt>ActiveRecord::Base#attributes=</tt>.
#
# It's also possible to instantiate related objects, so a <tt>Client</tt>
# class belonging to the +clients+ table with a +master_id+ foreign key
# can instantiate master through <tt>Client#master</tt>.
#
# source://activemodel//lib/active_model/attribute_methods.rb#484
def method_missing(method, *args, **_arg2, &block); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#507
def respond_to?(method, include_private_methods = T.unsafe(nil)); end
# A +Person+ instance with a +name+ attribute can ask
# <tt>person.respond_to?(:name)</tt>, <tt>person.respond_to?(:name=)</tt>,
# and <tt>person.respond_to?(:name?)</tt> which will all return +true+.
def respond_to_without_attributes?(*_arg0); end
private
# source://activemodel//lib/active_model/attribute_methods.rb#535
def _read_attribute(attr); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#520
def attribute_method?(attr_name); end
# Returns a struct representing the matching attribute method.
# The struct's attributes are prefix, base and suffix.
#
# source://activemodel//lib/active_model/attribute_methods.rb#526
def matched_attribute_method(method_name); end
# @raise [ActiveModel::MissingAttributeError]
#
# source://activemodel//lib/active_model/attribute_methods.rb#531
def missing_attribute(attr_name, stack); end
module GeneratedClassMethods
def attribute_aliases; end
def attribute_aliases=(value); end
def attribute_aliases?; end
def attribute_method_patterns; end
def attribute_method_patterns=(value); end
def attribute_method_patterns?; end
end
module GeneratedInstanceMethods
def attribute_aliases; end
def attribute_aliases?; end
def attribute_method_patterns; end
def attribute_method_patterns?; end
end
end
# source://activemodel//lib/active_model/attribute_methods.rb#539
module ActiveModel::AttributeMethods::AttrNames
class << self
# We want to generate the methods via module_eval rather than
# define_method, because define_method is slower on dispatch.
#
# But sometimes the database might return columns with
# characters that are not allowed in normal method names (like
# 'my_column(omg)'. So to work around this we first define with
# the __temp__ identifier, and then use alias method to rename
# it to what we want.
#
# We are also defining a constant to hold the frozen string of
# the attribute name. Using a constant means that we do not have
# to allocate an object on each call to the attribute method.
# Making it frozen means that it doesn't get duped when used to
# key the @attributes in read_attribute.
#
# source://activemodel//lib/active_model/attribute_methods.rb#556
def define_attribute_accessor_method(owner, attr_name, writer: T.unsafe(nil)); end
end
end
# source://activemodel//lib/active_model/attribute_methods.rb#540
ActiveModel::AttributeMethods::AttrNames::DEF_SAFE_NAME = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/attribute_methods.rb#68
ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP = T.let(T.unsafe(nil), Regexp)
# source://activemodel//lib/active_model/attribute_methods.rb#76
module ActiveModel::AttributeMethods::ClassMethods
# Allows you to make aliases for attributes.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_methods :name
#
# alias_attribute :nickname, :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.nickname # => "Bob"
# person.name_short? # => true
# person.nickname_short? # => true
#
# source://activemodel//lib/active_model/attribute_methods.rb#204
def alias_attribute(new_name, old_name); end
# source://activemodel//lib/active_model/attribute_methods.rb#224
def alias_attribute_method_definition(code_generator, pattern, new_name, old_name); end
# source://activemodel//lib/active_model/attribute_methods.rb#375
def aliases_by_attribute_name; end
# Returns the original name for the alias +name+
#
# source://activemodel//lib/active_model/attribute_methods.rb#258
def attribute_alias(name); end
# Is +new_name+ an alias?
#
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#253
def attribute_alias?(new_name); end
# Declares a method available for all attributes with the given prefix
# and suffix. Uses +method_missing+ and <tt>respond_to?</tt> to rewrite
# the method.
#
# #{prefix}#{attr}#{suffix}(*args, &block)
#
# to
#
# #{prefix}attribute#{suffix}(#{attr}, *args, &block)
#
# An <tt>#{prefix}attribute#{suffix}</tt> instance method must exist and
# accept at least the +attr+ argument.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_affix prefix: 'reset_', suffix: '_to_default!'
# define_attribute_methods :name
#
# private
# def reset_attribute_to_default!(attr)
# send("#{attr}=", 'Default Name')
# end
# end
#
# person = Person.new
# person.name # => 'Gem'
# person.reset_name_to_default!
# person.name # => 'Default Name'
#
# source://activemodel//lib/active_model/attribute_methods.rb#176
def attribute_method_affix(*affixes); end
# Declares a method available for all attributes with the given prefix.
# Uses +method_missing+ and <tt>respond_to?</tt> to rewrite the method.
#
# #{prefix}#{attr}(*args, &block)
#
# to
#
# #{prefix}attribute(#{attr}, *args, &block)
#
# An instance method <tt>#{prefix}attribute</tt> must exist and accept
# at least the +attr+ argument.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_prefix 'clear_'
# define_attribute_methods :name
#
# private
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.clear_name
# person.name # => nil
#
# source://activemodel//lib/active_model/attribute_methods.rb#107
def attribute_method_prefix(*prefixes, parameters: T.unsafe(nil)); end
# Declares a method available for all attributes with the given suffix.
# Uses +method_missing+ and <tt>respond_to?</tt> to rewrite the method.
#
# #{attr}#{suffix}(*args, &block)
#
# to
#
# attribute#{suffix}(#{attr}, *args, &block)
#
# An <tt>attribute#{suffix}</tt> instance method must exist and accept at
# least the +attr+ argument.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_methods :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.name_short? # => true
#
# source://activemodel//lib/active_model/attribute_methods.rb#141
def attribute_method_suffix(*suffixes, parameters: T.unsafe(nil)); end
# Declares an attribute that should be prefixed and suffixed by
# +ActiveModel::AttributeMethods+.
#
# To use, pass an attribute name (as string or symbol). Be sure to declare
# +define_attribute_method+ after you define any prefix, suffix or affix
# method, or they will not hook in.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
#
# # Call to define_attribute_method must appear after the
# # attribute_method_prefix, attribute_method_suffix or
# # attribute_method_affix declarations.
# define_attribute_method :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.name # => "Bob"
# person.name_short? # => true
#
# source://activemodel//lib/active_model/attribute_methods.rb#324
def define_attribute_method(attr_name, _owner: T.unsafe(nil)); end
# Declares the attributes that should be prefixed and suffixed by
# +ActiveModel::AttributeMethods+.
#
# To use, pass attribute names (as strings or symbols). Be sure to declare
# +define_attribute_methods+ after you define any prefix, suffix, or affix
# methods, or they will not hook in.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name, :age, :address
# attribute_method_prefix 'clear_'
#
# # Call to define_attribute_methods must appear after the
# # attribute_method_prefix, attribute_method_suffix or
# # attribute_method_affix declarations.
# define_attribute_methods :name, :age, :address
#
# private
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
# end
#
# source://activemodel//lib/active_model/attribute_methods.rb#285
def define_attribute_methods(*attr_names); end
# source://activemodel//lib/active_model/attribute_methods.rb#212
def eagerly_generate_alias_attribute_methods(new_name, old_name); end
# source://activemodel//lib/active_model/attribute_methods.rb#218
def generate_alias_attribute_methods(code_generator, new_name, old_name); end
# Removes all the previously dynamically defined methods from the class, including alias attribute methods.
#
# class Person
# include ActiveModel::AttributeMethods
#
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_method :name
# alias_attribute :first_name, :name
#
# private
# def attribute_short?(attr)
# send(attr).length < 5
# end
# end
#
# person = Person.new
# person.name = 'Bob'
# person.first_name # => "Bob"
# person.name_short? # => true
#
# Person.undefine_attribute_methods
#
# person.name_short? # => NoMethodError
# person.first_name # => NoMethodError
#
# source://activemodel//lib/active_model/attribute_methods.rb#368
def undefine_attribute_methods; end
private
# The methods +method_missing+ and +respond_to?+ of this module are
# invoked often in a typical rails, both of which invoke the method
# +matched_attribute_method+. The latter method iterates through an
# array doing regular expression matches, which results in a lot of
# object creations. Most of the time it returns a +nil+ match. As the
# match result is always the same given a +method_name+, this cache is
# used to alleviate the GC, which ultimately also speeds up the app
# significantly (in our case our test suite finishes 10% faster with
# this cache).
#
# source://activemodel//lib/active_model/attribute_methods.rb#408
def attribute_method_patterns_cache; end
# source://activemodel//lib/active_model/attribute_methods.rb#412
def attribute_method_patterns_matching(method_name); end
# Define a method `name` in `mod` that dispatches to `send`
# using the given `extra` args. This falls back on `send`
# if the called name cannot be compiled.
#
# source://activemodel//lib/active_model/attribute_methods.rb#421
def define_proxy_call(code_generator, name, proxy_target, parameters, *call_args, namespace:); end
# source://activemodel//lib/active_model/attribute_methods.rb#391
def generated_attribute_methods; end
# source://activemodel//lib/active_model/attribute_methods.rb#380
def inherited(base); end
# @return [Boolean]
#
# source://activemodel//lib/active_model/attribute_methods.rb#395
def instance_method_already_implemented?(method_name); end
# source://activemodel//lib/active_model/attribute_methods.rb#387
def resolve_attribute_name(name); end
end
# source://activemodel//lib/active_model/attribute_methods.rb#448
class ActiveModel::AttributeMethods::ClassMethods::AttributeMethodPattern
# @return [AttributeMethodPattern] a new instance of AttributeMethodPattern
#
# source://activemodel//lib/active_model/attribute_methods.rb#453
def initialize(prefix: T.unsafe(nil), suffix: T.unsafe(nil), parameters: T.unsafe(nil)); end
# source://activemodel//lib/active_model/attribute_methods.rb#462
def match(method_name); end
# source://activemodel//lib/active_model/attribute_methods.rb#468
def method_name(attr_name); end
# Returns the value of attribute parameters.
#
# source://activemodel//lib/active_model/attribute_methods.rb#449
def parameters; end
# Returns the value of attribute prefix.
#
# source://activemodel//lib/active_model/attribute_methods.rb#449
def prefix; end
# Returns the value of attribute proxy_target.
#
# source://activemodel//lib/active_model/attribute_methods.rb#449
def proxy_target; end
# Returns the value of attribute suffix.
#
# source://activemodel//lib/active_model/attribute_methods.rb#449
def suffix; end
end
# source://activemodel//lib/active_model/attribute_methods.rb#451
class ActiveModel::AttributeMethods::ClassMethods::AttributeMethodPattern::AttributeMethod < ::Struct
# Returns the value of attribute attr_name
#
# @return [Object] the current value of attr_name
def attr_name; end
# Sets the attribute attr_name
#
# @param value [Object] the value to set the attribute attr_name to.
# @return [Object] the newly set value
def attr_name=(_); end
# Returns the value of attribute proxy_target
#
# @return [Object] the current value of proxy_target
def proxy_target; end
# Sets the attribute proxy_target
#
# @param value [Object] the value to set the attribute proxy_target to.
# @return [Object] the newly set value
def proxy_target=(_); end
class << self
def [](*_arg0); end
def inspect; end